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 2000 Forums
 Transact-SQL (2000)
 IN problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-02-27 : 12:02:38
Gerardo writes "Hi,
Using the IN statement isn't working. I'm a T-SQL programmer and it's is the first time this append to me.

TableName: Production
Files: Prod_Id NCHAR(20) PRIMARY KEY, Date DATETIME, etc.
Records (example):
Prod_Id Date
20038311 2006-02-01 14:51:34.170
20038338 2006-02-01 19:45:22.307
20038361 2006-02-01 20:07:32.707

I'm doing this:
DECLARE @Analized AS nvarchar(1000)
SET @Analized = N'20038311'
SET @Analized = @Analized + N', ' + N'20038338'
SET @Analized = @Analized + N', ' + N'20038361'
PRINT @Analized
SELECT * FROM Production
WHERE Prod_Id IN (@Analized)

and doesn't work :s .

I don't have idea what's happening. Do you have one?

MSSQL version: 2000 SP4 running in Windows 2003 Standard Ed SP1

In advance thanks!

Gerardo."

graz
Chief SQLTeam Crack Dealer

4149 Posts

Posted - 2006-02-27 : 12:02:39
Please read the FAQ for dynamic SQL
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-02-27 : 13:13:09
Hi Gerardo, Welcome to SQL Team!

See http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=WHERE+IN+@MyCSV

Kristen
Go to Top of Page

gPg
Starting Member

1 Post

Posted - 2006-03-03 : 13:11:05
Kristen,
Thanks very much. Its a very good article's compilation.

I'm a active reader of this site, but now I registered to interchange ideas.

--
Gerardo Palazuelos
Go to Top of Page
   

- Advertisement -