hello guys, i know this not the right forum but i thought there are quite a good number of SQL Server 2000 gurus as well, to help me out. i have the following piece of Code in T-SQL.The variable @strIMEIColl has more than 20 Comma Seperated list of IMEI numbers, but still the Select statement wont show any thing. The PRINT @strIMEIColl statement shows the values correctly.Code:DECLARE @strIMEIColl VarChar(8000) DECLARE @strIMEI VarChar(15) DECLARE curMatched CURSOR FOR SELECT DISTINCT(IMEI) FROM IC_Data OPEN curMatched FETCH NEXT FROM curMatched INTO @strIMEI SELECT @strIMEIColl = CHAR(39) + @strIMEI + Char(39) FETCH NEXT FROM curMatched INTO @strIMEI WHILE @@FETCH_STATUS = 0 BEGIN select @strIMEIColl = @strIMEIColl + ',' + CHAR(39) + @strIMEI + Char(39) FETCH NEXT FROM curMatched INTO @strIMEI END WHILE @strIMEI = '' BEGIN SELECT @strIMEIColl = @strIMEIColl + ',' + @strIMEI FETCH NEXT FROM curMatched INTO @strIMEI END CLOSE curMatched DEALLOCATE curMatched PRINT @strIMEIColl SELECT * FROM IC_Data WHERE IMEI IN(@strIMEIColl)
I tried using
Please tell me where am i getting wrong, or is there an alternative to it also ?!?!


Reply With Quote

