Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
picasso
Starting Member
3 Posts |
Posted - 2013-06-04 : 01:09:53
|
Sorry for re-posting. I posted it in the wrong section.I have two tables that can be compared as follows:Select Col1 from DBTables where ltrim(rtrim(Col1)) not in (select ltrim(rtrim(Col2)) from DBTables where Col2 is not null)order by 1Select Col2 from DBTables where ltrim(rtrim(Col2)) not in (select ltrim(rtrim(Col1)) from DBTables where Col1 is not null)order by 1I would like to create a SP that takes two parameters Col1 and COl2 (e.g. EXEC myStoreProc col1, col2)any help is greatly appreciated |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-04 : 01:14:49
|
Hmm...why does your column nams come from a parameter? why does it change it runtime? Why not just write it static way as columns in table are fixed?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
picasso
Starting Member
3 Posts |
Posted - 2013-06-04 : 19:13:56
|
Basically I want the user to choose two columns at a time and compare them.I have a table with 16 columns but onlt two should be compared at a timethank you |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-04 : 23:48:56
|
then you need to use dynamic sql for that------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-05 : 02:42:11
|
Easiest way to do these kind of comparisons is to export column details to excel sheets from both tables and then use excel macros to do sheet comparisons.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
|
|
|