You cannot do this, but you can consider the function in sqlserver2005. Here is an example function that creates a table from a comma separated list
Create Function [dbo].[CsvToInt] ( @Array varchar(1000)) returns @IntTable table (IntValue int) AS begin declare @separator char(1) set @separator = ',' declare @separator_position int declare @array_value varchar(1000) set @array = @array + ',' while patindex('%,%' , @array) <> 0 begin select @separator_position = patindex('%,%' , @array) select @array_value = left(@array, @separator_position - 1) Insert @IntTable Values (Cast(@array_value as int)) select @array = stuff(@array, 1, @separator_position, '') end return end
And then just select from the function ...
Select * FROM dbo.CsvToInt('1,2,3,5')
And you will get the value of the table.
digiguru
source share