Friday, March 9, 2012

How to drop database table if it exits in sql mobile version?

Hi,

I am using VB.net and Visual Studio 2005 to compile a program for a Pocket PC with Microsoft? Windows Mobile? 2003 Second Edition. I am using sql mobile also.

What I want to complete is like one of the following two queries. But when I tried them in the sql mobile, errors happened. So how can I complete the same function in sql Mobile? Thanks.

USE DBa

if exists (select * from dbo.sysobjects

where id = object_id(N'[dbo].[Table_a]')

and OBJECTPROPERTY(id, N'IsUserTable') = 1)

drop Table Table_a

or

USE DBa

IF OBJECT_ID('dbo.Table_a) IS NOT NULL

DROP TABLE dbo.Table_a

You should issue a query to check if table exists and if it does issue another query to delete it.

Please see SQL CE/Mobile books online for queries (hint: look for Information_Schema.Tables and Drop Table).

|||Thanks a lot, and your suggestion is great

No comments:

Post a Comment