Tuesday, February 14, 2012

Do YOU see the syntax error?

Hey All,
I get error 170 on the select line(syntax) saying there is an error around the '='. To me this looks good, I must be missing something obvious - a second pair of eyes and maybe a working brain would really help me out - Thanks

DECLARE @.CylinderID int
DECLARE @.LocationID int
DECLARE @.CurrentLocID int

SELECT Distinct bl.[Date], i.BottleID = @.CylinderID, i.Loc_ID = @.LocationID
FROM [Bottle Location] bl, inserted i
WHERE bl.BottleID = i.BottleID
AND bl.[Date] = (SELECT max(bl.[DATE])
From [Bottle Location] bl, inserted i
WHERE bl.BottleID = i.BottleID)could you state exactly what are you trying to return here?

SELECT Distinct bl.[Date], i.BottleID = @.CylinderID, i.Loc_ID = @.LocationID

I get the feeling you are trying to return all rows where i.BottleID contains the same value as @.CylinderID and i.Loc_ID contains the same value as @.LocationID...|||Hey - I was trying to assign the value to the variables based on the most recent date in the location table for that cylinder. However, you were right, I wasn't writing it correctly. I re-wrote it and the syntax is good now. I'd still be sitting here though, so thanks for the comments. A second pair of eyes is sometimes the greatest help!|||Glad you got it straightened out!

No comments:

Post a Comment