cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Sybase db.execute if exist in vb6 & SQL

Former Member
0 Likes
9,211

Hi, I am looking at this too many hours again. In Microsoft SQL via vb6 front end.

I use: db.Execute "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[BuildFileAllOthersCDC]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)" & _ "drop table [dbo].[BuildFileAllOthersCDC]"

In Sybase with the same VB program. I am trying to use: myConnTM.Execute "if exists (select * from sysobjects where name=" 'mytable' " = 1) drop table 'mytable'"

I have tried all froms of this, all I can think of, does the "if exists" work with SYBASE SQL? I get an error, "Syntax error near if line one" Will trade gray hairs for suggestions... smile

George

View Entire Topic
VolkerBarth
Contributor

What version of SQL Anywhere are you using?

Version 11.0.1 and above support the "DROP TABLE IF EXISTS MyTable" syntax, by this omitting the need to check beforehand if the table already exists.