You are here: Re: Best approach to sending field names dynamically « MsSQL Server « IT news, forums, messages
Re: Best approach to sending field names dynamically

Posted by Erland Sommarskog on 03/09/07 08:18

(maflatoun@gmail.com) writes:
> I have a C# web app that searches my database table using the
> following search parameters
>
> Search string, criteria (> < =) and the field you want to perform your
> search on. My understanding is that stored procedure is the way to go.
> What's the best way of doing this using stored procedures. Can I
> define a placeholder for the field name?
>
> Ex.
> SELECT field1, field2... FROM Table WHERE field1='value1' where field1
> and value1 are both sent from code.
>
> If it's not possible then what is the best way to approach this
> problem? I see so many searches like that on the internet. I can only
> do them with inline SQL and not stored procedure.

Yes, these sort of searches are not very easy to do with static SQL.
I have an article on my web site that discusses this topic in detail:
http://www.sommarskog.se/dyn-search.html.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация