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)
 unable to run IN query in cursor

Author  Topic 

kneel
Starting Member

36 Posts

Posted - 2007-08-17 : 05:29:10
Hello All,

I am writing cursor in stored procedure,In which i want some records which are passed thorough parameter @GroupIDList which is varchar. But in table Contacts datatype of group id is INT.

so it throws error as Syntax error converting the varchar value '73,443,343' to a column of data type int.

Does anybody know solution for it ?

ALTER PROCEDURE [dbo].[prDeleteGroups]
(
@UserID VARCHAR(20),
@GroupIDList VARCHAR(1000)
)
WITH RECOMPILE
AS

SET NOCOUNT ON
--SET @vchSQL = ''
SET @chMsgIDList = ''
SET @chMsgID = ''
SET @chUserID = ''

DECLARE @MSGID CURSOR
SET @MSGID = CURSOR
LOCAL
FAST_FORWARD
READ_ONLY
FOR

SELECT DISTINCT MsgID FROM Contacts WHERE GROUPID IN (@GroupIDList)

OPEN @MSGID
FETCH FROM @MSGID INTO @chMsgID

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-17 : 05:40:54
Refer this
http://vyaskn.tripod.com/passing_arrays_to_stored_procedures.htm



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kneel
Starting Member

36 Posts

Posted - 2007-08-18 : 03:50:54
Hi,
thanx for this. my problem is solved

--kneel
Go to Top of Page
   

- Advertisement -