Friday, March 9, 2012

Is it necessary to add a GO ?

We have to run two update statements:
update pthdbo.table14
set name = t3.sortname
from pthdbo.table14 as t1,
xxxxxx
AND
update pthdbo.table14
set streetname = t7.streetname
from pthdbo.table as t1,
yyyyyy
Can I run these 2 update statements together ? Is it
necessary for me to add a GO statement after running the
first UPDATE statement ? If YES, would you mind to let me
know why ?
ThanksJason
GO is a batch "breaker" and it is not TSQL command
If you run it on QA you may want to consider putting GO between an UPDATE
statements
"Jason" <anonymous@.discussions.microsoft.com> wrote in message
news:01e301c5b9bd$ab182150$a601280a@.phx.gbl...
> We have to run two update statements:
> update pthdbo.table14
> set name = t3.sortname
> from pthdbo.table14 as t1,
> xxxxxx
> AND
> update pthdbo.table14
> set streetname = t7.streetname
> from pthdbo.table as t1,
> yyyyyy
> Can I run these 2 update statements together ? Is it
> necessary for me to add a GO statement after running the
> first UPDATE statement ? If YES, would you mind to let me
> know why ?
> Thanks|||Additional information:
For the concept of batch, assume there are 10 statements in a batch. If the
fifth statement has a syntax error, none of the statements in the batch are
executed. If the batch is compiled, and the second statement then fails
while executing, the results of the first statement are not affected because
it has already executed.
Read the online help for more information and detailed explanation.
"Uri Dimant" <urid@.iscar.co.il> ¼¶¼g©ó¶l¥ó·s»D:OLbGPKcuFHA.3660@.tk2msftngp13.phx.gbl...
> Jason
> GO is a batch "breaker" and it is not TSQL command
> If you run it on QA you may want to consider putting GO between an UPDATE
> statements
>
> "Jason" <anonymous@.discussions.microsoft.com> wrote in message
> news:01e301c5b9bd$ab182150$a601280a@.phx.gbl...
>> We have to run two update statements:
>> update pthdbo.table14
>> set name = t3.sortname
>> from pthdbo.table14 as t1,
>> xxxxxx
>> AND
>> update pthdbo.table14
>> set streetname = t7.streetname
>> from pthdbo.table as t1,
>> yyyyyy
>> Can I run these 2 update statements together ? Is it
>> necessary for me to add a GO statement after running the
>> first UPDATE statement ? If YES, would you mind to let me
>> know why ?
>> Thanks
>|||Dear all,
Thank you for your advice.
In this way, I can add GO after both Update Statement. However, it seems
that the one after the 2nd Update Statement is optional AS there is nothing
behind it ?
use database1
GO
update pthdbo.table14
set name = t3.sortname
from pthdbo.table14 as t1,
xxxxxx
GO
update pthdbo.table14
set streetname = t7.streetname
from pthdbo.table as t1,
yyyyyy
GO
Thanks
"Lau Lei Cheong" <leu_lc@.yehoo.com.hk> wrote in message
news:edEK12cuFHA.3896@.TK2MSFTNGP15.phx.gbl...
> Additional information:
> For the concept of batch, assume there are 10 statements in a batch. If
> the fifth statement has a syntax error, none of the statements in the
> batch are executed. If the batch is compiled, and the second statement
> then fails while executing, the results of the first statement are not
> affected because it has already executed.
> Read the online help for more information and detailed explanation.
> "Uri Dimant" <urid@.iscar.co.il>
> ¼¶¼g©ó¶l¥ó·s»D:OLbGPKcuFHA.3660@.tk2msftngp13.phx.gbl...
>> Jason
>> GO is a batch "breaker" and it is not TSQL command
>> If you run it on QA you may want to consider putting GO between an
>> UPDATE statements
>>
>> "Jason" <anonymous@.discussions.microsoft.com> wrote in message
>> news:01e301c5b9bd$ab182150$a601280a@.phx.gbl...
>> We have to run two update statements:
>> update pthdbo.table14
>> set name = t3.sortname
>> from pthdbo.table14 as t1,
>> xxxxxx
>> AND
>> update pthdbo.table14
>> set streetname = t7.streetname
>> from pthdbo.table as t1,
>> yyyyyy
>> Can I run these 2 update statements together ? Is it
>> necessary for me to add a GO statement after running the
>> first UPDATE statement ? If YES, would you mind to let me
>> know why ?
>> Thanks
>>
>|||No. The first GO signals begining of a batch process(i.e. put it in batch
processing mode), and the second GO signal that's the end of it so it gets
executed.
"Jason" <anonymous@.discussions.microsoft.com> ¼¶¼g©ó¶l¥ó·s»D:OVvXrNeuFHA.3596@.TK2MSFTNGP15.phx.gbl...
> Dear all,
> Thank you for your advice.
> In this way, I can add GO after both Update Statement. However, it seems
> that the one after the 2nd Update Statement is optional AS there is
> nothing behind it ?
> use database1
> GO
> update pthdbo.table14
> set name = t3.sortname
> from pthdbo.table14 as t1,
> xxxxxx
> GO
> update pthdbo.table14
> set streetname = t7.streetname
> from pthdbo.table as t1,
> yyyyyy
> GO
> Thanks
> "Lau Lei Cheong" <leu_lc@.yehoo.com.hk> wrote in message
> news:edEK12cuFHA.3896@.TK2MSFTNGP15.phx.gbl...
>> Additional information:
>> For the concept of batch, assume there are 10 statements in a batch. If
>> the fifth statement has a syntax error, none of the statements in the
>> batch are executed. If the batch is compiled, and the second statement
>> then fails while executing, the results of the first statement are not
>> affected because it has already executed.
>> Read the online help for more information and detailed explanation.
>> "Uri Dimant" <urid@.iscar.co.il> ¼¶¼g©ó¶l¥ó·s»D:OLbGPKcuFHA.3660@.tk2msftngp13.phx.gbl...
>> Jason
>> GO is a batch "breaker" and it is not TSQL command
>> If you run it on QA you may want to consider putting GO between an
>> UPDATE statements
>>
>> "Jason" <anonymous@.discussions.microsoft.com> wrote in message
>> news:01e301c5b9bd$ab182150$a601280a@.phx.gbl...
>> We have to run two update statements:
>> update pthdbo.table14
>> set name = t3.sortname
>> from pthdbo.table14 as t1,
>> xxxxxx
>> AND
>> update pthdbo.table14
>> set streetname = t7.streetname
>> from pthdbo.table as t1,
>> yyyyyy
>> Can I run these 2 update statements together ? Is it
>> necessary for me to add a GO statement after running the
>> first UPDATE statement ? If YES, would you mind to let me
>> know why ?
>> Thanks
>>
>>
>

No comments:

Post a Comment