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
 Whats wrong with this statement?

Author  Topic 

GavinD1977
Yak Posting Veteran

83 Posts

Posted - 2007-06-04 : 06:40:39
Query analyser is saying there is an error near the WHERE keyword:


INSERT INTO EMPLOYEE_TABLE (BANK_ACC, SORT_CODE)
VALUES (63035391,603030)
WHERE 40 IN (SELECT EMPLOY_REF FROM EMPLOYEE_TABLE);


Thanks people.

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-06-04 : 06:46:18
It will return all the values if 40 is is returned from the subquery else no rows..

because only once the where caluse is evaluated, if true it returns all the rows else no rows..

Tell us what do you want to achieve?

--------------------------------------------------
S.Ahamed
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2007-06-04 : 06:49:01
You can't use a where clause with an the insert statement which uses a list of values. What are you trying to achieve?

Mark
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-06-04 : 06:51:37
IF EXISTS (SELECT * FROM EMPLOYEE_TABLE WHERE EMPLOY_REF = 40)
INSERT INTO EMPLOYEE_TABLE (BANK_ACC, SORT_CODE)
VALUES (63035391,603030)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-06-04 : 07:02:33
Oh, i did not see thta!!! , it is an insert statement, as others told u can't use a where clause in insert statement.


--------------------------------------------------
S.Ahamed
Go to Top of Page
   

- Advertisement -