Create a table with some data in it:
create table #data (name varchar(500))
insert into #data (name)
select 'Texas'
union
select 'LA'
union
select 'Kansas'
union
select 'New York'
-- Create Dest Table
create table #dest (id int, name varchar(500))
-- Select the code below to insert into #dest table
declare @vid int
set @vid = 1 <-- Any value
insert into #dest (id, name)
select @vid, s.name from
(select name from #data) s
------------------------------------------------------
insert into #dest (id, name)
select @vid , (select top 10 name from #data) <-- This will give subquery return more than 1 row error message
No comments:
Post a Comment