October 22, 2008 at 2:03 am
I get an syntax error, but I can't find it. If I test the query via the Query Builder in ASP.NET it works fine, but if I test in the browser then I get a syntax error.
SELECT tblProjects.ProjectId, tblProjects.ProjectName, tblProjects.ProjectDescription, tblProjects.Remarks, tblProjects.CompanyId, tblProjects.ContractNummer, tblProjects.DataSupplierId,
tblUsers.AuthRolId, tblTasks.UserId
FROM tblTasks LEFT OUTER JOIN
tblUsers ON tblTasks.UserId = tblUsers.UserId LEFT OUTER JOIN
tblProjects ON tblTasks.ProjectId = tblProjects.ProjectId
WHERE (tblProjects.CompanyId = @CompanyId) AND (@AuthRolId = 3) OR
(@AuthRolId = 1) AND (tblTasks.UserId = @UserId)
October 22, 2008 at 2:11 am
What error do you get?
With the variables declared it parses fine. I can't run it, because I don't have your tables
DECLARE @CompanyId int, @AuthRolId int, @UserId int
SELECT tblProjects.ProjectId, tblProjects.ProjectName, tblProjects.ProjectDescription, tblProjects.Remarks,
tblProjects.CompanyId, tblProjects.ContractNummer, tblProjects.DataSupplierId,
tblUsers.AuthRolId, tblTasks.UserId
FROM tblTasks LEFT OUTER JOIN
tblUsers ON tblTasks.UserId = tblUsers.UserId LEFT OUTER JOIN
tblProjects ON tblTasks.ProjectId = tblProjects.ProjectId
WHERE (tblProjects.CompanyId = @CompanyId) AND (@AuthRolId = 3) OR
(@AuthRolId = 1) AND (tblTasks.UserId = @UserId)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 22, 2008 at 3:53 am
Hello Gail,
Thanx for your quick reply. Below you can read the error I get:
There was an error executing the query. Please check the syntax of the command and if present, the types and values of the parameters and ensurre they are correct.
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
October 22, 2008 at 8:03 am
That's not a standard SQL Server error. There's also no way that a select statement alone will give a foreign key/null/unique constraint error. Those can only be thrown by an insert or update statement.
What exactly are you trying to do, what tool are you using?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply