mikelawrence
Programmer
I've just moved from sql server 2000 to 2005 and the following procedure no longer works. The only way i can get the sort to be passed as a parameter is to create a sql string as sorting by a parameter, e.g. sort by @sort does not work. The stored procedure works if i exec it from Management Studio but not from a web asp page which makes me think it is to do with privileges but i have granted access to public and do not know what else to do. Any ideas would be appreciated. Thanks mike
ALTER PROCEDURE [dbo].[RR_Report_Card_Screen]
@sort AS VARCHAR(50)
AS
IF @sort is null OR @sort = '' SET @sort='balance desc'
DECLARE @sqlStr AS VARCHAR(8000)
SET @sqlStr="SELECT " ;
SET @sqlStr=@sqlStr +"a.lastname+', '+a.firstname " ;
SET @sqlStr=@sqlStr +"FROM mem_Members m" ;
SET @sqlStr=@sqlStr +"ORDER BY "+@sort ;
EXEC (@sqlStr)
ALTER PROCEDURE [dbo].[RR_Report_Card_Screen]
@sort AS VARCHAR(50)
AS
IF @sort is null OR @sort = '' SET @sort='balance desc'
DECLARE @sqlStr AS VARCHAR(8000)
SET @sqlStr="SELECT " ;
SET @sqlStr=@sqlStr +"a.lastname+', '+a.firstname " ;
SET @sqlStr=@sqlStr +"FROM mem_Members m" ;
SET @sqlStr=@sqlStr +"ORDER BY "+@sort ;
EXEC (@sqlStr)