SELECT RolePages.PageName, RolePages.Allow, RolePages.RoleId, Roles.RoleName
FROM Roles INNER JOIN
RolePages ON RolePages.RoleId = Roles.RoleId
WHERE (Roles.RoleName = 'Anonymous')
WHEN I RUN THE ABOVE QUERY MY RESULTS ARE AS BELOW: ('Allow' is bit type column)
PageNameAllowRoleIdRoleName
Home 1 2Anonymous
Registeration 12Anonymous
SpecialUserMessage 12Anonymous
ForgotPassword 12Anonymous
BUT, WHEN I RUN THE same QUERY IN A STORED PROCEDURE THE RESULTS ARE:
PageNameAllowRoleIdRoleName
Home -1 2Anonymous
Registeration -12Anonymous
SpecialUserMessage -12Anonymous
ForgotPassword -12Anonymous
Can someone please tell me if this is a SQL Server bug and if it can be fixed ? I am using SQL Server 2000 Desktop version.Are you using different clients for this? What client are you using for the stored procedure. Access (and possibly OleDb in general - I do not know) uses -1 for true. TO be safe, I would alsways check for !=0 (or <>0 for you VB types).|||I am running the query in VS 2003 and seeing the results. Then I run the stored procedure containing this query in VS 2003. So its a straight run of the query/ stored procedure directly from the database. Is this what you were asking ?|||Never check for 1 or -1. Always check for 0. ADO and ADO.net use -1 for true and they convert SQL's 1 to -1 when you use either to access data from SQL. SQL uses 1 for true. They both use 0 for false, so use that.|||OK. Thanks for the help. I think, the idea is that anything other than '0' is treated as a 'True'. So then one could say even if the query return's a '1' and the stored procedure for the same query returns a '-1', they both will be considered 'True'. That makes the results of the query and the query inside a stored procedure 'consistent'.
Thanks once again to all who helped clarify this.
No comments:
Post a Comment