Reputation: 14687
Can anyone help me out?
I don't know why the following SQL gives a syntax error:
if not exists (select 1 from sysobjects where type='U' and name='pg_result')
create table pg_result (parent char(10), child char(10))
else
delete from pg_result
end if
I'm getting the following error:
[Error] Script lines: 141-146
Incorrect syntax near the keyword 'end'.
Msg: 156, Level: 15, State: 2
Server: SYBDEV, Line: 5
I'm running:
Adaptive Server Enterprise/12.5.4/EBF 16785 ESD#10/P/Sun_svr4/OS 5.8/ase1254/2159/64-bit/FBO/Mon Nov 2 13:08:08 2009
Any ideas please?
Upvotes: 0
Views: 7496
Reputation: 21495
try
if not exists (select 1 from sysobjects where type='U' and name='pg_result')
create table pg_result (parent char(10), child char(10))
else
delete from pg_result
or
if not exists (select 1 from sysobjects where type='U' and name='pg_result')
begin
create table pg_result (parent char(10), child char(10))
end
else
begin
delete from pg_result
end
Upvotes: 1