I have the following SP: CREATE PROCEDURE sp_GetInformation @UserType varchar (10), @EntityID int AS DECLARE @SQL varchar (255) Select @SQL= 'SELECT Entities.Entity AS Entity, Users.UserName, Users.FName, Users.Lname, Users.Active, Users.UserType, Users.Pwd FROM Entities INNER JOIN Users ON Entities.EntityID = Users.EntityID' + CASE When @UserType = 'Admin' THEN ' Where @EntityID = ' + Convert(varchar,@EntityID) ELSE '' END + ' ORDER BY Users.Lname' EXEC @SQL GO
When I run it, I receive the following error: Server: Msg 203, Level 16, State 2, Procedure sp_GetInformation, Line 9 The name 'SELECT Entities.Entity AS Entity, Users.UserName, Users.FName, Users.Lname, Users.Active, Users.UserType, Users.Pwd FROM Entities INNER JOIN Users ON Entities.EntityID = Users.EntityID Where @EntityID = 3 ORDER BY Users.Lname' is not a valid identifier. Can anyone tell me what I am doing wrong? Thanks, Bruce -- Bruce Sorge BHS Web Design www.bhswebdesign.com ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
