Wednesday, March 28, 2012

How to make OrderBy by Parameters

Hello All,
I need to make a select in a table, but i need to do a order by by
parameter.
Exemple:
SELECT * FROM CUSTOMERS
ORDER BY @.COLUMN
This select is a stored procedure.
@.Column is the name of the column in my table.
@.Column i need to send by parameter.
I need to make a dynamic sort, but i don't can to use EXEC(''), because of
SqlInject.
Somebody to know how to make this task?
Thanks.
Dexter"Dexter" <projenet@.yahoo.com.br> schrieb im Newsbeitrag
news:uPgavPERFHA.248@.TK2MSFTNGP15.phx.gbl...
> Hello All,
> I need to make a select in a table, but i need to do a order by by
> parameter.
> Exemple:
> SELECT * FROM CUSTOMERS
> ORDER BY @.COLUMN
> This select is a stored procedure.
> @.Column is the name of the column in my table.
> @.Column i need to send by parameter.
> I need to make a dynamic sort, but i don't can to use EXEC(''), because of
> SqlInject.
> Somebody to know how to make this task?
> Thanks.
> Dexter
>|||DOnt think there is prober way to do this without dynamic SQL:
http://www.sommarskog.se/dynamic_sql.html
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Dexter" <projenet@.yahoo.com.br> schrieb im Newsbeitrag
news:uPgavPERFHA.248@.TK2MSFTNGP15.phx.gbl...
> Hello All,
> I need to make a select in a table, but i need to do a order by by
> parameter.
> Exemple:
> SELECT * FROM CUSTOMERS
> ORDER BY @.COLUMN
> This select is a stored procedure.
> @.Column is the name of the column in my table.
> @.Column i need to send by parameter.
> I need to make a dynamic sort, but i don't can to use EXEC(''), because of
> SqlInject.
> Somebody to know how to make this task?
> Thanks.
> Dexter
>|||http://www.4guysfromrolla.com/webtech/010704-1.shtml
"Dexter" <projenet@.yahoo.com.br> wrote in message
news:uPgavPERFHA.248@.TK2MSFTNGP15.phx.gbl...
> Hello All,
> I need to make a select in a table, but i need to do a order by by
> parameter.
> Exemple:
> SELECT * FROM CUSTOMERS
> ORDER BY @.COLUMN
> This select is a stored procedure.
> @.Column is the name of the column in my table.
> @.Column i need to send by parameter.
> I need to make a dynamic sort, but i don't can to use EXEC(''), because of
> SqlInject.
> Somebody to know how to make this task?
> Thanks.
> Dexter
>|||How do I use a variable in an ORDER BY clause?
http://www.aspfaq.com/show.asp?id=2501
AMB
"Dexter" wrote:

> Hello All,
> I need to make a select in a table, but i need to do a order by by
> parameter.
> Exemple:
> SELECT * FROM CUSTOMERS
> ORDER BY @.COLUMN
> This select is a stored procedure.
> @.Column is the name of the column in my table.
> @.Column i need to send by parameter.
> I need to make a dynamic sort, but i don't can to use EXEC(''), because of
> SqlInject.
> Somebody to know how to make this task?
> Thanks.
> Dexter
>
>sql

No comments:

Post a Comment