ALTER proc spPrincipalTest ( @uid varchar(30) ) as DECLARE @ufilter nvarchar(200) DECLARE @uexpdate datetime DECLARE @CMD nvarchar(200) select @ufilter=ufilter, @uexpdate=uexpdate from UFILTERS where uid=@uid Print @ufilter IF ISNULL(@ufilter, 'ZZTOP') = 'ZZTOP' BEGIN select * from dvASTUCurrentShort where 1 = 2 END IF @ufilter = 'NONE' BEGIN select * from dvASTUCurrentShort order by Lastname, Firstname END ELSE BEGIN set @cmd = 'select * from dvASTUCurrentShort where ' + @ufilter print @cmd exec sp_executesql @cmd, @ufilter END Output: schoolnum='032' select * from dvASTUCurrentShort where schoolnum='032' Incorrect syntax near 'schoolnum'. No rows affected. (0 row(s) returned) @RETURN_VALUE = 0 Finished running [dbo].[spPrincipalTest].
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.