SQLServerCentral.com / General / Programming / Stored Procedure and Parameters Table / Latest PostsInstantForum.NET v2.9.0SQLServerCentral.comhttp://www.sqlservercentral.com/Forums/notifications@sqlservercentral.comTue, 03 Mar 2015 17:07:29 GMT20RE: Stored Procedure and Parameters Tablehttp://www.sqlservercentral.com/Forums/Topic1516525-23-1.aspxYeah, that's what Im looking for! Thank you very much!Thu, 21 Nov 2013 12:38:15 GMTMeatloafRE: Stored Procedure and Parameters Tablehttp://www.sqlservercentral.com/Forums/Topic1516525-23-1.aspx[quote][b]rayh 98086 (11/21/2013)[/b][hr]Hi,Thank you. The part I am getting hung up on or just don't understand is having the parameters for a where statement be variable. How do I make sure the sytax stays complete. Thank you for article will readh now.[/quote]Like this?[code]declare @scriptname varchar(10) = 'fruit'SELECT * FROM ScriptParameters WHERE scriptname = @scriptname AND Active = 1[/code]Or if you are wanting to make this into a stored procedure...[code]create procedure GetScriptStuff( @scriptname varchar(10)) as SELECT * FROM ScriptParameters WHERE scriptname = @scriptname AND Active = 1 [/code]Then you could call your stored proc like this:[code]exec GetScriptStuff @scriptname = 'fruit'[/code]Thu, 21 Nov 2013 12:30:43 GMTSean LangeRE: Stored Procedure and Parameters Tablehttp://www.sqlservercentral.com/Forums/Topic1516525-23-1.aspxHi,Thank you. The part I am getting hung up on or just don't understand is having the parameters for a where statement be variable. How do I make sure the sytax stays complete. Thank you for article will readh now.Thu, 21 Nov 2013 12:23:52 GMTMeatloafRE: Stored Procedure and Parameters Tablehttp://www.sqlservercentral.com/Forums/Topic1516525-23-1.aspx[quote][b]rayh 98086 (11/21/2013)[/b][hr]To all:I am creating a paramaters table to store values for mulitple sctipts.For example, I will create a Table called ScriptParameters with the fields ID, scriptname, ScriptValue, and active.Sample data may be:ID, scriptname, scriptvalue,active1, fruit, apple,12, fruit, grapes,03, fruit, oranges,14, veggies, peas,15, veggies, corn,16, veggies, spinach,17, veggies, carrots,18, candy, chocolate,19, candy, lollipops,0I want to create a query that will allow me to check and return all values with active fruit dynamically.If I did this hardcoded, it would look like this:SELECT * FROM ScriptParameters WHERE scriptvalue='apple' OR scriptvalue='grapes' OR scriptvalue='oranges' AND Active='1'How can I make the scriptvalue dynamic and maintain the proper syntax?Any advice would be greatly appreciated![/quote]Why do you have to list all the scriptvalues? Can't you use the scriptname?[code]SELECT * FROM ScriptParameters WHERE scriptname = 'fruit' AND Active = 1[/code]I suspect you might also get a lot of benefit from reading this article about catch all type queries. [url=http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/]http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/[/url]Thu, 21 Nov 2013 12:01:59 GMTSean LangeStored Procedure and Parameters Tablehttp://www.sqlservercentral.com/Forums/Topic1516525-23-1.aspxTo all:I am creating a paramaters table to store values for mulitple sctipts.For example, I will create a Table called ScriptParameters with the fields ID, scriptname, ScriptValue, and active.Sample data may be:ID, scriptname, scriptvalue,active1, fruit, apple,12, fruit, grapes,03, fruit, oranges,14, veggies, peas,15, veggies, corn,16, veggies, spinach,17, veggies, carrots,18, candy, chocolate,19, candy, lollipops,0I want to create a query that will allow me to check and return all values with active fruit dynamically.If I did this hardcoded, it would look like this:SELECT * FROM ScriptParameters WHERE scriptvalue='apple' OR scriptvalue='grapes' OR scriptvalue='oranges' AND Active='1'How can I make the scriptvalue dynamic and maintain the proper syntax?Any advice would be greatly appreciated!Thu, 21 Nov 2013 11:10:02 GMTMeatloaf