Wednesday, March 7, 2012

how to comment out a block of codes in SQL Query Analyzer?

Hello,
I know '--' can be used to comment out a single line. I tried /* and */ but
got the follow errors.
/*use master
go
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Server: Msg 113, Level 15, State 1, Line 1
Missing end comment mark '*/'.
Server: Msg 170, Level 15, State 1, Line 8
Line 8: Incorrect syntax near '*'.
Thanks,
Bingbing wrote on Tue, 29 Nov 2005 09:02:15 -0800:

> Hello,
> I know '--' can be used to comment out a single line. I tried /* and */
> but got the follow errors.
> /*use master
> go
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
> Server: Msg 113, Level 15, State 1, Line 1
> Missing end comment mark '*/'.
> Server: Msg 170, Level 15, State 1, Line 8
> Line 8: Incorrect syntax near '*'.
> Thanks,
> Bing
The GO is being interpreted as a batch delimiter. Just add some additional
markers around the GO.
/*
use master
*/
go
/*
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Dan|||"Daniel Crichton" wrote:

> bing wrote on Tue, 29 Nov 2005 09:02:15 -0800:
>
>
> The GO is being interpreted as a batch delimiter. Just add some additional
> markers around the GO.
> /*
> use master
> */
> go
> /*
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
>
Ah, ok, thanks much for the heads-up.
Bing

No comments:

Post a Comment