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
 SQL Server Development (2000)
 Problems with a CURSOR

Author  Topic 

Valentino999
Starting Member

2 Posts

Posted - 2002-02-28 : 03:48:13
Hi folks,

I would like do Declare a cursor like this:

Declare @mytest varchar(500)

SET @mytest = 'test1, test2, test3'

Declare test_cursor CURSOR LOCAL FOR
SELECT * FROM test WHERE testit IN(@mytest)

HOW CAN I DO THAT??????

Thanks

nr
SQLTeam MVY

12543 Posts

Posted - 2002-02-28 : 03:57:17
Why would you want to declare a cursor - they are never necessary and usually counter-productive.

try
SELECT * FROM test WHERE ',' + replace(@mytest,' ','') + ',' like '%,' + testit + ',%'

or look at the faq on csv strings.

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Valentino999
Starting Member

2 Posts

Posted - 2002-02-28 : 04:04:12
Hey Thanks very much

It works correctly

Go to Top of Page
   

- Advertisement -