June 20, 2011 at 12:53 am
Stored Procedure -How to Pass @SortColumn And @SortOrder
June 20, 2011 at 2:40 am
vinaseetha87 (6/20/2011)
Stored Procedure -How to Pass @SortColumn And @SortOrder
I did not understand your question correctly. Stilly try to reply with.
Syntax:
EXEC dbo.spStoredProcedureName @SortCOlumn = 'ColumnName', @SortOrder = 'SortOrder'
For example:
EXEC dbo.spAddressList @SortCOlumn = 'City', @SortOrder = 'ASC'
June 20, 2011 at 11:37 am
vinaseetha87 (6/20/2011)
Stored Procedure -How to Pass @SortColumn And @SortOrder
SQL is a declarative language, i.e. this does not work:
DECLARE @SortOrder NCHAR(4),
@SortColumn SYSNAME ;
SET @SortOrder = 'ASC' ;
SET @SortColumn = N'name' ;
SELECT *
FROM master.sys.tables
ORDER BY @SortColumn @SortOrder ;
Why are you trying to offer this functionality from SQL? Changing the order of results is better left to the presentation layer.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply