Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Inserisci più righe nella tabella temporanea con un comando in SQL2005

Prova qualcosa come

CREATE TABLE #TEMP 
( 
    Node int 
) 


DECLARE @textXML XML
DECLARE @data NVARCHAR(MAX), 
        @delimiter NVARCHAR(5)
SELECT  @data = '-1,-1,-1,-1,701,-1,-1,-1,-1,-1,304,390,403,435,438,439,442,455 ',
        @delimiter = ','
SELECT    @textXML = CAST('<d>' + REPLACE(@data, @delimiter, '</d><d>') + '</d>' AS XML)

INSERT INTO #TEMP
SELECT  T.split.value('.', 'nvarchar(max)') AS data
FROM    @textXML.nodes('/d') T(split)

SELECT * FROM #TEMP

DROP TABLE #TEMP