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 |
aoriju
Posting Yak Master
156 Posts |
Posted - 2011-03-28 : 06:30:51
|
DECLARE @tbl_Test AS TABLE( ID INT IDENTITY(1,1), EMPID INT, NAME VARCHAR(100))INSERT INTO @tbl_Test VALUES(1,'TEST'),(2,'TEST1') , (3, NULL), (4,'TEST2'),(4,'TEST3')I want to take SELECT * FROM @tbl_Test WHERE NAME = CASE WHEN EMPID =3 THEN NAME IS NOTNULL ENDHow to write this |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-03-28 : 07:04:40
|
Not quite clear to me the logic that you are trying to implement. Are you trying to select everything where the name is not null? If so,SELECT * FROM @tbl_Test WHERE NAME IS NOT NULL Or, if you are trying to pick the name if there is a name and pick the employee id if there is no name, thenselect isnull(name,id) from @tbl_Test |
 |
|
|
|
|
|
|