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
 Simple SQL problem

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-02-11 : 15:00:40
This simple SQL doesn't let me add the
order by
or where clause
at the end.

What am I doing wrong?

SELECT "RM00101"."CUSTNMBR", "RM00101"."CUSTNAME", "SOP10200"."EXTDCOST", "SOP10200"."XTNDPRCE", "SOP10100"."DOCDATE", "SOP10100"."SOPTYPE",
"SOP10200"."OXTNDPRC", "SOP10200"."QUANTITY", "SOP10100"."SOPNUMBE", "SOP10100"."FRTAMNT", "SOP10100"."SUBTOTAL"
FROM ("PBS"."dbo"."SOP10200" "SOP10200" INNER JOIN "PBS"."dbo"."SOP10100" "SOP10100"
ON ("SOP10200"."SOPTYPE"="SOP10100"."SOPTYPE") AND ("SOP10200"."SOPNUMBE"="SOP10100"."SOPNUMBE"))
INNER JOIN "PBS"."dbo"."RM00101" "RM00101" ON "SOP10100"."CUSTNMBR"="RM00101"."CUSTNMBR"

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-02-11 : 15:13:22
Sorry never mind, i see the issue, i wasn't qualifying the names
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-11 : 15:18:42
Using double-quotes around Table/Column names is a bit old-hat nowadays ....

MS SQL preference is to use [MyObjectName] instead

Not sure if double-quotes is actually deprecated (or if deprecation has even been announced)
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-02-11 : 15:37:58
Sorry about the DQ's. I took it straightout of Crystal reprts. altho it does work on the SQL Server 2008 studio still.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-12 : 03:03:53
" I took it straightout of Crystal reprts."

Marvellous! Well I'm glad you didn't write it like that
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-12 : 03:29:23
quote:
Originally posted by Kristen

" I took it straightout of Crystal reprts."

Marvellous! Well I'm glad you didn't write it like that


Haven't you worked with CR before?
It also does it

Madhivanan

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

Kristen
Test

22859 Posts

Posted - 2010-02-12 : 03:42:15
Nope. My SQL is all beautifully hand made
Go to Top of Page
   

- Advertisement -