0
-- 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(),[email protected]
WHERE TaskID in (SELECT * FROM udf_Split (@TasksToUpdate,','))
指定的長度'DECLARE @TasksToUpdate varchar'。如果未指定長度,則默認爲'VARCHAR(1)'。 – DMason
使用varchar(max)具有最大的靈活性。 –