@thatraja U r right....to help a bit more I tried to write the procedure for him....
CREATE PROC sp_Sortdata
@OrderByColumnName nvarchar(15)
AS
DECLARE @SQLStatement nvarchar(max)
SET @SQLStatement = N'select * from emp order by '+@OrderByColumn
EXEC sp_executesql @statement = @SQLStatement
Now execute the created stored proc by using
exec sp_SortData @OrderByColumnName='ColumnName'
Here ColumnName is the name of the column by which you want to do the sorting
Simple isn't :cool:
If you like my answer please, vote it or mark it as answer.