|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Variable Syntax Queries
Greetings all. I'm not sure if what I'm trying to accomplish is possible, so bear with me.
I'm trying to make a single statement which variable where statements. For example: Declare @variable varchar(20) set @variable = 'segment' Declare @syntax_variable varchar(50) set @syntax_variable = 'where column = '@variable'' Select Column from DataBase @syntax_variable = @variable So the output that the server would get would be: Select Column From DataBase where column = 'segment' This way I could set my front end web page to be able to set values for what operators I use with if statements. I already do this with VB using line joins &_ and &vbcrlf. But I'd rather keep the sql out of the source and use a stored procedure. The above code obviously does not work, but its the only way I can illustrate what I'm trying to accomplish. Any ideas? Last edited by twifosp : July 24th, 2003 at 01:41 PM. |
|
#2
|
|||
|
|||
|
If you are going to hardcode variable values in the stored procedure why not just define the values explicitly or use some sort of logic based on incoming values.
|
|
#3
|
|||
|
|||
|
The values can't be defined.
For example if I have a where statement based on a column value, then that is fine. I can always have that where statement. But I need the functionality to be able to choose more than one or ALL column values. Making that where statement and or additional ands optional. I could accomplish this by making my query after several if statements, but when you are potentially doing this with 7 columns, it gets nasty quick. I figured out a way to do this, using a huge varchar to store my query in, unfortunetly it doesn't seem to want to work in a stored proc and I can't figure out why. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Variable Syntax Queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|