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
 Incorrect syntax

Author  Topic 

kdnichols
Posting Yak Master

232 Posts

Posted - 2007-02-15 : 12:56:22
Hello,

I am getting a Incorrect syntax near the word group in this clause.


from Parser_ocr
Inner Join Parser_ojb on order_no_ocr = order_no_ojb
Inner JOIN RGV_Codes on substring (compl_cde_ojb, 1, 3) = CODE
Inner JOIN csg.hist_sbb_Base on hse_key_ocr = hse_key_sbb
where substring (compl_cde_ojb, 16, 3) = CODE
and ir_tech_ojb between 950 and 999
and compl_dte_ojb BETWEEN '&low' AND '&high'
and prin_ocr = 8600
GROUP BY ir_tech_ojb, substring (compl_cde_ojb, 16, 3),compl_dte_ojb,DES, res_name_sbb, ADDR1_HSE,
job_typ_ojb, job_class_ojb, order_no_ocr, ls_chg_op_id_ocr, CommissionAUT)
group by rollup(TECHN, RESCODE,(COMPLET, DESCRIPTION, NAME, ADDRESS, JOB, TYP, NUMB, OPR))
order by 1, 2,3, 5;


What do I need to fix?

Thanks,

Kurt

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 13:15:17
GROUP BY ... WITH ROLLUP

There are lot of good books for ORACLE programmers who wants to go T-SQL.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-02-15 : 13:34:57
order by 1, 2,3, 5;

This is no longer allowed in SQL Server 2005 (compatibility mode of 90).

Tara Kizer
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 14:33:32
[code]select compatibility_level from sys.databases
where name = 'test'
--90
SELECT @@VERSION
--Microsoft SQL Server 2005 - 9.00.3033.00 (Intel X86) Dec 6 2006 17:53:12 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

DECLARE @Test TABLE (c VARCHAR, d VARCHAR)

INSERT @Test
SELECT 'c', 'q' UNION ALL
SELECT 'b', 'w' UNION ALL
SELECT 'a', 'e' UNION ALL
SELECT 'c', 'h'

select * From @test order by 1, 2


OUTPUT

p1 p2
------ ------
a e
b w
c h
c q[/code]
Peter Larsson
Helsingborg, Sweden
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-02-15 : 14:41:56
I wonder why it fails for us then in our stored procedures for 2 projects. SQL Server Books Online for 2005 also indicates that it will fail.

Developers had to change a bunch of stored procedures in order to get them to work on 90.

Tara Kizer
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 14:45:07
May it changed back with SP2?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 14:47:13
Taken from SQL Server 2005 Books Online (SP2)
quote:
order_by_expression
Specifies a column on which to sort. A sort column can be specified as a name or column alias, or a nonnegative integer representing the position of the name or alias in the select list. An integer cannot be specified when the order_by_expression appears in a ranking function. A sort column can include an expression, but when the database is in SQL Server 2005 (90) compatibility mode the expression cannot resolve to a constant. Column names and aliases can be qualified by the table or view name. In SQL Server 2005, qualified column names and aliases are resolved to columns listed in the FROM clause. If order_by_expression is not qualified, the value must be unique among all columns listed in the SELECT statement.

Multiple sort columns can be specified. The sequence of the sort columns in the ORDER BY clause defines the organization of the sorted result set.

The ORDER BY clause can include items that do not appear in the select list. However, if SELECT DISTINCT is specified, or if the statement contains a GROUP BY clause, or if the SELECT statement contains a UNION operator, the sort columns must appear in the select list.

Additionally, when the SELECT statement includes a UNION operator, the column names or column aliases must be those specified in the first select list.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-02-15 : 15:11:06
Isn't SP2 still in Beta?

My BOL (SP1) indicates the same thing as yours. Perhaps we were running the RTM version when we got all of the errors. I did not reverify BOL for my last post, I was going on memory of when we got the errors. They all had to do with the ordinal numbers in the ORDER BY. I don't recall the exact specifics of the queries though as this was quite a few months ago. They may have had derived tables in them.

Tara Kizer
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 15:18:29
There are so many "editions" of service packs right now, so I don't know what it is, more than the official Community Technology Preview (CTP).
A list of fixes made in this is available here
http://support.microsoft.com/kb/921896/

The top reason I upgraded was that I were annoyed by having to connect and login for every new query window I started.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-15 : 15:18:59
And there is both EDIT and DESIGN menu alternatives on the database context popup menu!


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-02-15 : 15:23:10
quote:
Originally posted by Peso


The top reason I upgraded was that I were annoyed by having to connect and login for every new query window I started.



I hate that too! I'm glad to hear that it is fixed.

Tara Kizer
Go to Top of Page

kdnichols
Posting Yak Master

232 Posts

Posted - 2007-02-16 : 09:45:26
Hello,

This is really cool to see everyone put there heads together to find solutions for each other!

That is what I like about this forum.

Thanks everyone!

Kurt
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-16 : 09:48:07
Continued here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=79264


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -