Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MS SQL Server
 tsql trouble
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Anacrusis
Junior Member

USA
219 Posts

Posted - 12 December 2003 :  09:38:30  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
Can anybody tell me why this doesn't work?

declare @Actions varchar(15) 
select @Actions = '''NFP'''

select @Actions = @Actions + ',''LVU'''

select @Actions
select * from POINT_ACTIONS
where P_ENABLED = 1 
and P_ACTION  in (@Actions)

The Internet ClubHouse
www.internet-clubhouse.com

Anacrusis
Junior Member

USA
219 Posts

Posted - 12 December 2003 :  09:42:51  Show Profile  Visit Anacrusis's Homepage  Send Anacrusis an AOL message
sorry, I should be more specific. The last query returns no rows, But if I run the exact same thing, replacing the @Actions with the actual value, I get 2 rows back. I don't understand why it does that.

The Internet ClubHouse
www.internet-clubhouse.com
Go to Top of Page

grazman
Junior Member

USA
193 Posts

Posted - 12 December 2003 :  13:03:13  Show Profile  Visit grazman's Homepage
Yeah, T-SQL doesn't support using a variable for an IN clause. You can do it using dynamic SQL ( http://www.sqlteam.com/item.asp?ItemID=4619 ) but that's not usually a great solution. T-SQL is pretty picky about where you can use @variables.

SQLTeam.com - For SQL Server Developers and Administrators
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.15 seconds. Powered By: Snitz Forums 2000 Version 3.4.07