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 |
u2envy1
Yak Posting Veteran
77 Posts |
Posted - 2008-12-05 : 03:24:45
|
I have a join on two tables & a created column. I am unable to do a search on that column.SQL statement :Select col1, col2, col3, 'T' As MyColFrom Table1Where (MyCol IN (@MyCol))UNIONSelect col1, col2, col3, 'A' As MyColWhere (MyCol IN (@MyCol))From Table2 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-12-05 : 11:37:08
|
quote: Originally posted by u2envy1 I have a join on two tables & a created column. I am unable to do a search on that column.SQL statement :Select col1, col2, col3, 'T' As MyColFrom Table1Where (MyCol IN (@MyCol))UNIONSelect col1, col2, col3, 'A' As MyColWhere (MyCol IN (@MyCol))From Table2
These are virtual columns . You need to create real Column with Alter table add columnname.... |
|
|
u2envy1
Yak Posting Veteran
77 Posts |
Posted - 2008-12-08 : 05:06:33
|
Thx |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-13 : 01:51:15
|
quote: Originally posted by u2envy1 Thx
however you could do like thisSELECT *FROM(Select col1, col2, col3, 'T' As MyColFrom Table1UNIONSelect col1, col2, col3, 'A' As MyColFrom Table2)tWhere ',' + @MyCol +',' LIKE '%,' + MyCol + ',%' |
|
|
|
|
|
|
|