Execute an insert in the temporary table in SQL SERVER

1

I have the following code below.

declare @ac varchar (max) = '(' + replace ('2398,2399,2405,2407,2523,3509,3510,3518,3523,3524,3601,3859,4713,4728,4735,47362398,2399,2405, 2407,2523,3509,3510,3518,3523,3524,3601,3859,4713,4728,4735,4736 ',', ','), (') +') '

select @ac

declare

@myList table (number bigint)

insert into @myList values @ac

select * from @myList

But for some reason is not going already tried a cast what could it be?

    
asked by anonymous 13.05.2016 / 00:57

1 answer

1

Try this:

declare @ac varchar(max)
declare @myList table (ac varchar(max))
begin
    set @ac = '(' + replace('2398,2399,2405,2407,2523,3509,3510,3518,3523,3524,3601,'+
                         '3859,4713,4728,4735,47362398,2399,2405,2407,2523,3509,' +                        '3510,3518,3523,3524,3601,3859,4713,4728,4735,4736',',','),(') + ')'
    insert into @myList values ( @ac )
    select * from @myList
end
    
13.05.2016 / 18:46