| Author |
Topic  |
|
|
nietzky
Yak Posting Veteran
63 Posts |
Posted - 01/03/2013 : 16:34:04
|
SELECT RecID, ServerName, projectID, PM, Environment, STATUS, DEPLOY_STAGE1, DEPLOY_STAGE2, PRIORITY, LOCATION, LOCATION_ORIGINAL, PM_ROLE, DO_TYPE from MYTABLE
I would like to write an efficient query to search and find a string value in multiple columns of a table. From .net C# app I have a textbox with a search button. User puts in a string and all rows that match that string come back. The string can be in several columns. The sp should take only 1 paramater - the search string. These are all columns on which I would liek to conduct the search. ServerName, projectID, PM, Environment, STATUS, PRIORITY, LOCATION, PM_ROLE,DO_TYPE
Thank you for any help |
Edited by - nietzky on 01/03/2013 16:47:10
|
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48119 Posts |
|
|
nietzky
Yak Posting Veteran
63 Posts |
Posted - 01/04/2013 : 06:17:13
|
How do I pass the variable to that sp if database is MyDB and table is MYTABLE? Could I just use the logic below? I have no more than 10K records to search, records are archived every year so the size is not an issue.
SELECT RecID, ServerName, projectID, PM, Environment, STATUS, DEPLOY_STAGE1, DEPLOY_STAGE2, PRIORITY, LOCATION, LOCATION_ORIGINAL, PM_ROLE, DO_TYPE from MYTABLE
where ServerName like @string OR projectID like @string OR PM like string OR Environment like @string OR and so on
|
Edited by - nietzky on 01/04/2013 06:22:06 |
 |
|
|
nigelrivett
Flowing Fount of Yak Knowledge
United Kingdom
3328 Posts |
Posted - 01/04/2013 : 06:28:37
|
That looks like the easiest way to do it as you have a fixed number of columns for the search.
========================================== Cursors are useful if you don't know sql. SSIS can be used in a similar way. Beer is not cold and it isn't fizzy. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48119 Posts |
Posted - 01/04/2013 : 10:31:43
|
if its a small dataset then that looks like a good method
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
nietzky
Yak Posting Veteran
63 Posts |
Posted - 01/04/2013 : 19:16:36
|
| Thank you |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48119 Posts |
Posted - 01/04/2013 : 20:41:20
|
welcome
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|