Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Posts
    13

    Unanswered: Why does this not work (declare and go)

    Hi everyone,

    Can someone tell me why the following those note work...

    Code:
    declare @testing int
    go
    
    select @testing = 1
    go
    
    select @testing
    go
    It complains that I must declare variable '@testing'.

    But this those work...

    Code:
    declare @testing int
    select @testing = 1
    select @testing
    go
    In a nutshell I'm trying to write a script that is using a cursor, and it seems that to be able to use a cursor in a script I need to have 'go' after all statements.

    Thanks!

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    "go" is the batch terminator. It separates logical groupings of SQL statements.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •