TSQL error

I have 2 tsql queries but they contain some error. can anyone find that error.

 JOIN ship ON job.job_id = ship.job_id
 JOIN recipient ON ship.airbill = recipient.airbill
 job.job_id = 112 AND
 ship.airbill = '11222333' AND
 recipient.email = 'asdf@asdf.com'
 SELECT p1.user,
 p1.value 'email',
 p2.value 'billing_type',
 p3.value 'billing_id_1',
 p4.value 'billing_id_2',
 p5.value 'office_id'
 FROM pss_pref p1
 JOIN pss_pref p2 ON p1.user = p2.user AND p2.field = 'billing_type'
 JOIN pss_pref p3 ON p1.user = p3.user AND p3.field = 'billing_id_1'
 JOIN pss_pref p4 ON p1.user = p4.user AND p4.field = 'billing_id_2'
 JOIN pss_pref p5 ON p1.user = p5.user AND p5.field = 'office_id'
 p1.user = 'remery' AND p1.field = 'email'
more ▼

asked Nov 20, 2012 at 07:53 PM in Default

avatar image

0 1 1 1

It would help if you gave us the error message, as it could be something as simple as the table doesn't exist, but we have no way of knowing.

Nov 20, 2012 at 07:57 PM Kev Riley ♦♦
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Not knowing what error you're hitting, it's hard to give you a good answer. The first query parses just fine. The second query does get parsing errors on my system because of the column named 'user'. Modifying the code to use [user] instead of just the text eliminates the parsing error.

more ▼

answered Nov 21, 2012 at 01:30 PM

avatar image

Grant Fritchey ♦♦
137k 20 43 81

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Nov 20, 2012 at 07:53 PM

Seen: 671 times

Last Updated: Nov 26, 2012 at 01:55 AM

Copyright 2016 Redgate Software. Privacy Policy