I have the following string variable to split into temp table.
Example:
DECLARE @Str VARCHAR(MAX) = '10000,200000'
Now I want it to store in #Temp
table.
Like this:
Table: #Temp
Cola Colb
--------------
10000 200000
I have the following string variable to split into temp table.
Example:
DECLARE @Str VARCHAR(MAX) = '10000,200000'
Now I want it to store in #Temp
table.
Like this:
Table: #Temp
Cola Colb
--------------
10000 200000
Assuming that your columns is not varchar
CREATE TABLE #Temp
(
Col1 int,
Col2 int
)
DECLARE @Str VARCHAR(MAX) = '10000,200000'
DECLARE @SQLString VARCHAR(MAX) = 'INSERT #Temp Select ' + @Str
EXEC (@SQLString)