Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problem with Insert

Author  Topic 

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-08-29 : 09:06:02
create table one (id int)

create table two (id int, name varchar(20)

insert into two (id, name)
values
select id from dbo.one where id=2,
'abc'



when i'm trying to insert values in the table 'two'
with the help of above query
it is showing the followin error

Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'select'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near ','.



Can anyone help me on this

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-29 : 09:11:37
insert into two (id, name)
select id, 'abc' from dbo.one
where id=2



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

haribabu.rk
Starting Member

2 Posts

Posted - 2008-08-30 : 00:49:22
create table one (id int)

INSERT INTO one
select 2

create table two (id int, name varchar(20))

insert into two
select id,'abc' from one where id=2

try this.
Go to Top of Page
   

- Advertisement -