-- This query works using the split function
SELECT AssignUserID,* FROM dbo.Task WHERE TaskID in (SELECT * FROM udf_Split ('1269469,1359508',','))
--this script using the @TasksToUpdate parameter does not work.
--If I replace the parameter @TasksToUpdate with the string in the where clause then it does work
DECLARE @NewUser varchar
DECLARE @TasksToUpdate varchar
DECLARE @UpdateUser VARCHAR(30)
SET @NewUser = 'aaronteamlead'
SET @TasksToUpdate = '1269469,1359508'
SET @UpdateUser = 'updateusername'
UPDATE dbo.Task
SET AssignUserID = @NewUser,LastUpdatedDt=getdate(),LastUpdatedUser=@UpdateUser
WHERE TaskID in (SELECT * FROM udf_Split (@TasksToUpdate,','))
答案 0 :(得分:0)
DMason是对的。
"指定DECLARE @TasksToUpdate varchar的长度。如果未指定长度,则默认为VARCHAR(1)。 "