• 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

    create procedure aa

    as

    begin

    if exists (select * from sys.objects where name='bb')

    begin

    drop procedure bb

    GO

    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?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass