Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sybase: Incorrect syntax near 'go' in a 'IF EXISTS' block

Tags:

tsql

sybase

This is my sql statement

IF EXISTS (select 1 from sysobjects where name = 'PNL_VALUE_ESTIMATE')
  drop table dbo.PNL_VALUE_ESTIMATE
go

isql bails out with this error message

Msg 102, Level 15, State 1:
Server 'DB_SERVER', Line 3:
Incorrect syntax near 'go'.

But the sql statement look correct to me. What's wrong?

Sybase version is 15

like image 725
Anthony Kong Avatar asked Nov 25 '22 05:11

Anthony Kong


1 Answers

Try this:

IF EXISTS (select 1 from sysobjects where name = 'PNL_VALUE_ESTIMATE')
  drop table dbo.PNL_VALUE_ESTIMATE

go

or this:

IF EXISTS (select 1 from sysobjects where name = 'PNL_VALUE_ESTIMATE')
BEGIN
  drop table dbo.PNL_VALUE_ESTIMATE
END

go

or this:

IF EXISTS (select 1 from sysobjects where name = 'PNL_VALUE_ESTIMATE')
BEGIN
  select 1
END

go

Does any work?

like image 197
aF. Avatar answered Nov 27 '22 18:11

aF.