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 statement

Author  Topic 

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-09-01 : 01:30:28
Hi when i'm trying to retrieve values from two tables like the Query below

insert into dbo.two (id, name)
values select id,name
from one,names where id=2 and
name ='Arul Raj A'

It is throwing me the following Error--

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'id'.


Can anyone help me on this - how to insert the data into one table.. where the values are retreived from more than one table where the tables does not have any kind of relation

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-01 : 01:40:37
[code]
insert into dbo.two (id, name)
values select id,name
from one,names where id=2 and
name ='Arul Raj A'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-09-01 : 01:44:11
Hey its the same what i posted.. Still it shows the same error..No change..Give me a correct solution
Go to Top of Page

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-09-01 : 01:49:00
quote:
Originally posted by swathigardas

Hey its the same what i posted.. Still it shows the same error..No change..Give me a correct solution



Are you making a request or ordering people here to help you. Please have some gratitude for people helping you.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-01 : 01:59:25
quote:
Originally posted by swathigardas

Hey its the same what i posted.. Still it shows the same error..No change..Give me a correct solution


not the same. I strike off the values


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

swathigardas
Posting Yak Master

149 Posts

Posted - 2008-09-01 : 02:07:41
Hey thanks Khtan..I dint check it properly.. it was really helpful for me..Thanks a lot
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-01 : 03:28:49
quote:
Originally posted by swathigardas

Hey thanks Khtan..I dint check it properly.. it was really helpful for me..Thanks a lot


It is a copy/paste error

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -