Re: Passing a variable column name to a stored procedure
From: Steve B. (SteveB_at_discussions.microsoft.com)
Date: 12/20/04
- Next message: Kevin McDonnell [MSFT]: "Re: IIS, SQL DMZ question"
- Previous message: tw-Nashville: "Re: Active Directory SQL integration"
- In reply to: Adam Machanic: "Re: Passing a variable column name to a stored procedure"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 20 Dec 2004 13:25:02 -0800
Many thanks and happy holidays!
Steve B.
"Adam Machanic" wrote:
> http://www.sommarskog.se/dyn-search.html
>
>
> --
> Adam Machanic
> SQL Server MVP
> http://www.sqljunkies.com/weblog/amachanic
> --
>
>
> "Steve B." <SteveB@discussions.microsoft.com> wrote in message
> news:DA49E65E-5170-4B2F-B6CA-C98DEBFACC81@microsoft.com...
> > For security purposes, I make a practice of using stored procedures rather
> > than SQL statements in my VBScript code. However, I cannot find a way to
> pass
> > a column name as a stored-procedure variable. I need to do something like
> the
> > following.
> >
> > CREATE PROCEDURE SearchTest
> > @SearchBy varchar(20) = Null,
> > @SearchString varchar(30) = Null,
> > AS
> >
> > Select ClaimNumber
> > From ClaimsHeader
> > Where CASE @SearchBy
> > WHEN 'Manufacturer' THEN MgfrName
> > WHEN 'StoreNumber' THEN Store#
> > ELSE ClaimNumber
> > END
> > = @SearchString
> >
> > This, of course, won't even pass the syntax check.
> >
> > I am allowing the user to both search and sort on any of seven displayed
> > columns, so writing all the SELECT statements for all the possible
> > combinations would make the stored procedure a monster. It is easy to
> build
> > the SQL statement needed in VBScript, but then SQL injection becomes an
> > issue. Any suggestions?
> >
> > TIA...
>
>
>
- Next message: Kevin McDonnell [MSFT]: "Re: IIS, SQL DMZ question"
- Previous message: tw-Nashville: "Re: Active Directory SQL integration"
- In reply to: Adam Machanic: "Re: Passing a variable column name to a stored procedure"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|