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 |
|
gongxia649
So Suave
344 Posts |
Posted - 2006-11-09 : 11:30:34
|
| I'm trying to compare the fields if they are equal, retrieve it.Because null <> null.i cant retrieve the record. Is there anyway to retrive the records by comparing all the fields?declare @table table(ad_num int null,ad_str1 varchar(50) null, ad_num_suffix_a varchar (10) null,ad_num_suffix_b varchar (10) null,ad_unit varchar(10) null,ad_num_test int null,ad_str1_test varchar(50) null, ad_num_suffix_a_test varchar (10) null,ad_num_suffix_b_test varchar (10) null,ad_unit_test varchar(10) null,passed bit)insert @table (ad_str1, ad_str1_test)select 'apple road orad RD' , 'apple road orad RD' select ad_num , ad_num_test, ad_str1 , ad_str1_test, ad_num_suffix_a , ad_num_suffix_a_test , ad_num_suffix_b , ad_num_suffix_b_test ,ad_unit , ad_unit_test, passed from @tableselect * from @table where ad_num = ad_num_testand ad_str1 = ad_str1_test ad_num_suffix_a = ad_num_suffix_a_test and ad_num_suffix_b = ad_num_suffix_b_testand ad_unit = ad_unit_test |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-09 : 11:40:26
|
How about using ISNULL()?select * from @table where isnull(ad_num,0) = IsNull(ad_num_test,0)and Isnull(ad_str1, '') = IsNull(ad_str1_test,'').... Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
|
gongxia649
So Suave
344 Posts |
Posted - 2006-11-09 : 11:45:05
|
| why didnt i think about that?thanks. |
 |
|
|
|
|
|
|
|