﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Administering / SQL Server 2005  / create Procedure within Procedure / 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>Thu, 23 May 2013 05:42:30 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: create Procedure within Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic970280-146-1.aspx</link><description>or it shud be like belowcreate procedure aaasbegin        if exists (select * from sys.objects where name='bb')        begin                                drop procedure bb                declare @a nvarchar(max)                set @a='create procedure bb as begin print ''bb''               end'                                exec sp_executesql @a        endendBut as Gail's suggestion.... why u want to do this??? is this some class room based question???</description><pubDate>Tue, 17 Aug 2010 06:38:51 GMT</pubDate><dc:creator>Ramji29</dc:creator></item><item><title>RE: create Procedure within Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic970280-146-1.aspx</link><description>Well, the GO in the 'middle' of procedure A ends the batch. Hence leaving a begin without an end and, in the second batch an end without a begin.GO is a batch breaker. It tells SSMS where to delimit the batches sent to SQL. So what you're telling SSMS is that the first batch it must send is[code="sql"]create procedure aaasbegin        if exists (select * from sys.objects where name='bb')        begin                                drop procedure bbGO[/code]As I'm sure you can see, that is not valid SQL.Again, I need to ask why you want a procedure to create a procedure? What's the point?</description><pubDate>Tue, 17 Aug 2010 06:06:23 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: create Procedure within Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic970280-146-1.aspx</link><description>Hi,Thanks for reply[code]create procedure aaasbegin        if exists (select * from sys.objects where name='bb')        begin                                drop procedure bb                go                              declare @a nvarchar(max)                set @a='create procedure bb as begin print ''bb''               end'				exec sp_executesql @a        endend[/code]after run this code i got following error message[code]Msg 102, Level 15, State 1, Procedure aa, Line 9Incorrect syntax near 'bb'.Msg 156, Level 15, State 1, Line 7Incorrect syntax near the keyword 'end'.[/code]</description><pubDate>Tue, 17 Aug 2010 05:57:45 GMT</pubDate><dc:creator>Trouble Shooter</dc:creator></item><item><title>RE: create Procedure within Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic970280-146-1.aspx</link><description>Is there a question here? Your code looks like it should work, just add an EXEC to run the dynamic sQL you generated.I do have to ask... Why?</description><pubDate>Tue, 17 Aug 2010 05:49:35 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>create Procedure within Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic970280-146-1.aspx</link><description>Hi,I want to create procedure within proceduresomething like that[code]create procedure aaasbegin	if exists (select * from sys.objects where name='bb')	begin				drop procedure bb		go				declare @a nvarchar(max)		set @a='create procedure bb as begin print ''bb''		end'	endend[/code]Thanks in Advance</description><pubDate>Tue, 17 Aug 2010 05:47:19 GMT</pubDate><dc:creator>Trouble Shooter</dc:creator></item></channel></rss>