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.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Reporting services 2008 Search on created column

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 MyCol
From Table1
Where (MyCol IN (@MyCol))
UNION
Select col1, col2, col3, 'A' As MyCol
Where (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 MyCol
From Table1
Where (MyCol IN (@MyCol))
UNION
Select col1, col2, col3, 'A' As MyCol
Where (MyCol IN (@MyCol))
From Table2



These are virtual columns . You need to create real Column with Alter table add columnname....
Go to Top of Page

u2envy1
Yak Posting Veteran

77 Posts

Posted - 2008-12-08 : 05:06:33
Thx
Go to Top of Page

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 this
SELECT *
FROM
(
Select col1, col2, col3, 'T' As MyCol
From Table1
UNION
Select col1, col2, col3, 'A' As MyCol
From Table2
)t
Where ',' + @MyCol +',' LIKE '%,' + MyCol + ',%'

Go to Top of Page
   

- Advertisement -