﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 General Discussion  / Parameter passing / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 14:32:22 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Parameter passing</title><link>http://www.sqlservercentral.com/Forums/Topic452480-149-1.aspx</link><description>I'm pretty sure I'm old fashioned, but I still use OUTPUT parameters in some situations. Let's say you have a situation where the application normally creates a row in a table and then creates rows in the child table. The usual call is to spcTable1 which returns the SCOPE_IDENTITY for the row it inserted and the app then passes this on to spcTable2. But what if you also have to support a set based approach where you receive an XML file or something and need to process the same procedures in a single stored proc:[code]Declare @MyId intEXEC spcTable1 @Param1 = 'SomeValue', @Param2 = @MyId OUTPUT--this executes the procedure and captures the output which you then pass on to the next procEXEC spcTable2 @Param3 = @MyId[/code]It's a simplistic example, but it gives you the idea.</description><pubDate>Thu, 07 Feb 2008 05:44:58 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Parameter passing</title><link>http://www.sqlservercentral.com/Forums/Topic452480-149-1.aspx</link><description>An output parameter can be used to assign a variable the result of a stored procedure. Less used now that we have user-defined functions.For dynamic Sql, it's something like[code]declare @cmd varchar(8000), @a char(2)select @a = 'US'select @cmd = 'select gemName,gemType,Statefrom GEmTable where country=' + @Aexec(@cmd)[/code]That's dynamic SQL. A regular query would beselect gemName, gemType, State from GemTable where country = @a</description><pubDate>Wed, 06 Feb 2008 20:03:45 GMT</pubDate><dc:creator>Steve Jones - SSC Editor</dc:creator></item><item><title>Parameter passing</title><link>http://www.sqlservercentral.com/Forums/Topic452480-149-1.aspx</link><description>hi guys,i know how to pass input parameter to stored procs.why do we use output parameters in stored procs?would anyone suggest an example for that kind of stored procs?other question is about dynamic sqlcan i able to use the where clause in dynamic sql?eg: 'select gemName,gemType,State      from GEmTable where country=%A'when i used dynamic sql in my scripts using where clause,i had an error message.thank you very much for your time.regards,thaya</description><pubDate>Wed, 06 Feb 2008 16:00:27 GMT</pubDate><dc:creator>thaya2002</dc:creator></item></channel></rss>