I have a stored procedure that takes a string of a pipe delimited array of IDs and parses them out. I want to have this happen in a transaction, so don’t want to pass them in one at a time.
If I use varchar(max) as to not limit the size of the argument passed in, will this cause problems? I don’t see the limit being hit, but I also don’t want to guess or place an arbitrary limit on the string.
CREATE PROCEDURE myProc
@IDs varchar(max)
AS
BEGIN
...
END
GO
There’s not much to it.
varchar(max)behaves just like any varchar less than 8000 characters until you go above 8000 characters. There should be little to no difference betweenvarchar(200)andvarchar(max)if the actual data is less than 8000 characters. If you’re expecting smaller inputs but can’t rule out bigger inputs, avarchar(max)is great.