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
 Error in Syntax

Author  Topic 

darknoobie
Starting Member

4 Posts

Posted - 2013-12-20 : 11:27:37
I have a syntax error that I cannot seem to fix. I've been breaking my head and bout to give up. If anyone could help me it would be much appreciated.

EquipSQL = "SELECT Equipment.Network_Name, User_Information.Employee, Locations.Location FROM Equipment LEFT JOIN User_Information ON Equipment.Assigned_To = User_Information.ID LEFT JOIN Locations ON Equipment.Location = Locations.Location WHERE ((NOT(IsNULL(e.Assigned_To))) AND Equipment.Garbage=False AND Equipment.EquipmentType=1 ORDER BY Assigned_To"


Heres the error:
Syntax error (missing operator) in query expression 'Equipment.Assigned_To = User_Information.ID LEFT JOIN Locations ON Equipment.Location = Locations.Locatio'.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-12-20 : 11:32:11
what is the length for EquipSQL ? looks like the query is truncated ? try increase the length for EquipSQL


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

darknoobie
Starting Member

4 Posts

Posted - 2013-12-20 : 11:38:03
The EquipSQL is a vbscript variable. The error seems to be in the SQL Query
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-12-20 : 11:42:46
There is parenthesis missing (which formatting shows easily):

SELECT
Equipment.Network_Name,
User_Information.Employee,
Locations.Location
FROM
Equipment
LEFT JOIN
User_Information
ON Equipment.Assigned_To = User_Information.ID
LEFT JOIN
Locations
ON Equipment.Location = Locations.Location
WHERE
( -- No matching end
(
NOT
(
IsNULL(e.Assigned_To)
)
)
AND Equipment.Garbage=False
AND Equipment.EquipmentType=1
ORDER BY
Assigned_To


EDIT: I guess it is VB, not a SQL string assignment.
Go to Top of Page

darknoobie
Starting Member

4 Posts

Posted - 2013-12-20 : 11:47:59
I fixed that syntax error as well as the literal string assignment and also fixed the e.Assigned_To to Equipment.Assigned_To. Still getting the same error.
Go to Top of Page

darknoobie
Starting Member

4 Posts

Posted - 2013-12-20 : 11:49:34
I should probably add that this is a Access Database I am querying
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-12-20 : 12:00:47
quote:
Originally posted by darknoobie

I should probably add that this is a Access Database I am querying

Doh, I don't use Access so I can't help you there. Someone here may know, otherwise you might want to try a forum that supports Access.
Go to Top of Page

waterduck
Aged Yak Warrior

982 Posts

Posted - 2013-12-20 : 12:23:35
IsNULL(e.Assigned_To) <-- this function need 2 argument?
sorry my bad...it doesn't look like tsql
Go to Top of Page
   

- Advertisement -