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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With