SQL Server Performance

Adding GO at the end of my procedure creation script causes an error. Why?

Discussion in 'SQL Server 2005 T-SQL Performance Tuning' started by MedImpact619, Mar 16, 2009.

  1. MedImpact619 New Member

    I am scripting procedures together so I can have one script that creates a series of procedures. i've come across 1 procedure that I've broken down as listed below and I get an error message when I add go at the end. I need to GO so I can go to my next procedure I will becreating in the script.
    CREATE PROCEDURE [dbo].[TestProc] (@Param1 INT, @Param2 INT OUTPUT)
    AS
    BEGIN
    print 'HELLO'
    END
    GO
    Error message is :
    Msg 102, Level 15, State 1, Procedure TestProc, Line 5
    Incorrect syntax near 'GO'.

  2. Adriaan New Member

    Nothing wrong with that CREATE script by itself, it should complete without error. The problem may well be in the next item of your script.
  3. MedImpact619 New Member

    thats the problem... there isn't anything after the go.. strange isn't it?
  4. Adriaan New Member

    I don't think the actual body of your procedure is just ...
    print 'HELLO'
    If there's any syntax problem in the actual body of the procedure, then GO will be the first thing that SQL Server can make sense of again.
  5. MedImpact619 New Member

    I had simplified the proc to the point of all it's doing is printing 'hello'...i disconnected from the database and re-connected now it compiles fine..
    i just wanted to know why I was getting the error message. if you don't have an answer; cool. i'm the type that wants to know what was happening so I can avoid it in the future.
  6. moh_hassan20 New Member

    Sometimes , when you copy and past from external unicode text editor or html page , there is hidden control chars (char with asci code 0-31) are inside the code and are not visible, and lead to a compilation error.

Share This Page