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

Dividi la stringa tramite l'istruzione select

DECLARE @LeftPart TABLE
(Agent int
)

DECLARE @RightPart TABLE
(Agent1 int
)

declare @Agent nvarchar(4000) = '2131235,334225';

INSERT INTO @LeftPart
SELECT LEFT(@Agent,7)

INSERT INTO @RightPart
SELECT RIGHT(@Agent,6)

SELECT * INTO #Temp
FROM 
(
SELECT * FROM @LeftPart
UNION ALL
SELECT * FROM @RightPart
)A

SELECT * FROM #Temp