parameters, update results, etc.

L

liz b

I'm slowly learning these two apps & TSQL in my free time
(with LOTS of downtime in between sessions) so please
forgive the ignorance:

I want to match two sets of fields from two tables, then
update the result set (verifying the matches, transfering
info from one tab to another, or rejecting the match so
it never occurs again). I want to avoid visual basic,
since I don't know it.

The following sp statement works well, and it matches a
text string from either table's name field with the
other, and the totals within a range:

(@start_string_number smallint,
@length_string_number smallint,
@dollar_difference numeric(10))
AS
SELECT @start_string_number AS 'start at letter #',
@length_string_number AS '# of letters',
@dollar_difference AS 'max $ difference',
f.Name AS 'Table A Name',
f.total AS 'Table A Tot',
ct.Name AS 'Table B Name',
ct.Total AS 'Table B Tot'
FROM dbo.tableA f
CROSS JOIN
dbo.TableB ct
WHERE (ct.Name LIKE '%' + SUBSTRING(f.Name,
@start_string_number, @length_string_number) + '%')
AND
(f.Total BETWEEN ct.Total - @dollar_difference
AND ct.Total + @dollar_difference)
OR
(f.Total BETWEEN ct.Total - @dollar_difference
AND ct.Total + @dollar_difference)
AND
(f.Name LIKE '%' + SUBSTRING(ct.name,
@start_string_number, @length_string_number) + '%')

....with params: @start_string_number = 1,
@length_string_number = 4,
@dollar_difference = 15
we'd get:

Tab A Name Tab A Tot Tab B Name Tab B Tot
---------- --------- ---------- ---------
Marge 500 Margarita 489

As I understand it, if I use a stored proc I can't update
the result set. If I use a view I can't pass
parameters.

What I want is a set of forms where
1) the parameters are entered, or defaults are accepted,
2) the result set is brought up,
3) I use some mechanism to mark the sets that should
stay together, bringing all of the information from one
table into the other, or mark the record set to never be
matched again.

Thanks for any ideas you might have.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top