Reputation: 7260
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
Upvotes: 3
Views: 10185
Reputation: 2287
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)
Upvotes: 6