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 |
|
paramu
Posting Yak Master
151 Posts |
Posted - 2011-06-11 : 09:15:07
|
| Hi,I like to have Select Query with comparing values between two fields and resultant as a single field, Is it possible?Select Field1,(len(trim(Field2))=0) and len(trim(Field3))>0) then Field3 as CmpField or(len(trim(Field2))>0) and len(trim(Field3))=0) then Field2 as CmpField or (len(trim(Field2))=0) and len(trim(Field3))=0) then Field2 as CmpFieldlike the above I want to have a select query...by comparing between Fiedl2 & Field3 and its resultant will give CmpField....Is It Possible?Thanks For The Ideas.Paramu @ PARANTHAMAN |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-06-11 : 09:37:54
|
[code]Select Field1, case when (len(trim(Field2))=0) and len(trim(Field3))>0) then Field3 as CmpField or when (len(trim(Field2))>0) and len(trim(Field3))=0) then Field2 as CmpField or (len(trim(Field2))=0) and len(trim(Field3))=0) then Field2 end as CmpField[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
paramu
Posting Yak Master
151 Posts |
Posted - 2011-06-11 : 09:44:31
|
| Hi Khtan,Really You Are Gods Gift For The People Like Me...!!!Thanks For Your All Replies..Paramu @ PARANTHAMAN |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-06-12 : 04:20:35
|
| is trim udf you created? SQL Server doesnt have trim by default.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|