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
 General SQL Server Forums
 New to SQL Server Programming
 INSERT INTO with WHERE

Author  Topic 

baps
Starting Member

3 Posts

Posted - 2009-09-19 : 12:39:33
Hi,

I feel a bit stupid asking this because it seems like the answer should be real easy but I'm getting an error each time I try:

INSERT INTO dbo.FirstTable (Last_Name)
VALUES ('Miller')
WHERE First_Name = 'Mary'

The following error comes up
Incorrect syntax near the keyword 'WHERE'

I'm trying to insert 'Miller' into the Last_Name column where First_Name is 'Mary'. Please help.

Thanks!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-09-19 : 12:51:56
You are trying to insert one new record and there is no reason to use WHERE clause and there is no sense to use WHERE clause.
Maybe you want to do an update?
update FirstTable
set Last_Name = 'Miller'
where First_Name = 'Mary'



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -