Wrong Syntax ??

Wrong Syntax ??

Post by Rey Roja » Fri, 19 Jan 2001 00:58:13



I am attempting to perform this query in Query Analyzer and I am receiving
the following errors:

If (Select MATRIXID From SUBSC Where (MATRIXID = '00233' Or MATRIXID =
'00203' Or MATRIXID = '00107' Or MATRIXID = '00010'))
Begin
 Update SUBSC
 Set TIER1 = 'P'
 Where ((Select AGEGRP From SUBSC Where AGEGRP = '1') And
  (Select FAMSIZ From SUBSC Where FAMSIZ = '1'))
End

Server: Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'BEGIN'.
Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'AND'.
Server: Msg 170, Level 15, State 1, Line 6
Line 6: Incorrect syntax near ')'.

Can anyone tell me what I am doing wrong with this query??

Thanks,

Rey

 
 
 

Wrong Syntax ??

Post by Andrew J. Kell » Fri, 19 Jan 2001 01:26:45


Rey,

A select statement doesn't return a true or false like that. Try using the
EXISTS command like:

IF EXISTS (SELECT * FROM ....)

--
Andrew J. Kelly
Targitmail.com


Quote:> I am attempting to perform this query in Query Analyzer and I am receiving
> the following errors:

> If (Select MATRIXID From SUBSC Where (MATRIXID = '00233' Or MATRIXID =
> '00203' Or MATRIXID = '00107' Or MATRIXID = '00010'))
> Begin
>  Update SUBSC
>  Set TIER1 = 'P'
>  Where ((Select AGEGRP From SUBSC Where AGEGRP = '1') And
>   (Select FAMSIZ From SUBSC Where FAMSIZ = '1'))
> End

> Server: Msg 156, Level 15, State 1, Line 2
> Incorrect syntax near the keyword 'BEGIN'.
> Server: Msg 156, Level 15, State 1, Line 5
> Incorrect syntax near the keyword 'AND'.
> Server: Msg 170, Level 15, State 1, Line 6
> Line 6: Incorrect syntax near ')'.

> Can anyone tell me what I am doing wrong with this query??

> Thanks,

> Rey


 
 
 

1. Replace function not working - wrong syntax issue?

Hello

I am trying to remove all instances of the word "Bargain" in the column
"ProductTitle" in the table "tblProducts"

Here is my code which I am trying to execute in Query Analyser.

select REPLACE (producttitle, 'BARGAIN' , '' ) from tblproducts
go

This returns the column with all the rows and also has deleted all the
"Bargain"s in the column. However these changes are not being made
permanently to the table. How do I actually Update the entries to
permanently get rid of the word?

Thanks

Richard

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.338 / Virus Database: 189 - Release Date: 14/03/2002

2. SQL Statement error

3. "Wrong syntax near Where keyword" in sql statement with table joins

4. Skills Management

5. Enterprise Manager "Wrong syntax near '\'"

6. how to add files/fields/indexes to ddf-files

7. What is wrong with my simple SQL syntax?

8. Postgres95 - Please help

9. What's wrong with this syntax?

10. Whats wrong with the syntax ?

11. run-time error 3001, syntax is wrong?

12. wrong DAO error: Syntax error in number in query expression