x

TSQL error

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

SELECT * FROM job
JOIN ship ON job.job_id = ship.job_id
JOIN recipient ON ship.airbill = recipient.airbill
WHERE
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'
WHERE
p1.user = 'remery' AND p1.field = 'email'
more ▼

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

bhasg08 gravatar image

bhasg08
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

Grant Fritchey gravatar image

Grant Fritchey ♦♦
98.5k 19 21 74

(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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

SQL Server Central

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

Topics:

x279

asked: Nov 20, 2012 at 07:53 PM

Seen: 543 times

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