2010-09-28 100 views

回答

1

嘗試看看這篇文章: http://www.codeproject.com/KB/database/SPParameters.aspx

你應該能夠用這個例子從文章來解決問題:

DECLARE @IDs varchar(100) 
SELECT @IDs = '429,446,552,1001, 332 , 471' 
    --Any IDs as an example 

SELECT Convert(Int, NullIf(SubString(',' + @IDs + ',' , ID , CharIndex(',' , ',' + @IDs + ',' , ID) - ID) , '')) AS IDList 
FROM tblToolsStringParserCounter 
WHERE ID <= Len(',' + @IDs + ',') AND SubString(',' + @IDs + ',' , ID - 1, 1) = ',' 
AND  CharIndex(',' , ',' + @IDs + ',' , ID) - ID > 0