question

jhunu avatar image
jhunu asked

SQL comparation

I have 3 table A, B C. Need to compare column col1, col2 in table A and B and also need to chk col3 between table A and C . After comparing the values in 3 table the , values need to be used in futher coding . How can it be done using cursor. i am able to handle comparation bethwwn first 2 tables but how to include the third table
sql-servertsql
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

SirSQL avatar image SirSQL commented ·
Firstly, do you have example schema that we can look at, and the code for the first comparison? Secondly, is there a particular reason that you wish to use a cursor? Set based operations generally perform a lot better and should be used in most scenarios.
3 Likes 3 ·
Magnus Ahlkvist avatar image Magnus Ahlkvist commented ·
How do you want to compare the values? How will the comparison be used? Please provide DDL as @SirSQL suggested, and please also provide example data and describe, using that data, what you want to achieve.
1 Like 1 ·
TimothyAWiseman avatar image TimothyAWiseman commented ·
Well, this won't directly address your question, but you may want to consider doing it without the cursor. As a rule of thumb, cursors perform poorly in SQL Server and they are very rarely the best approach to a problem.
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.