-- ==================================
-- create table t_subsidy_count_set
-- ==================================
if not exists (select * from sysobjects where type = 'U' and name = 't_subsidy_count_set')
create table t_subsidy_count_set(
ID int identity(1, 1) not null,
DMSSet char(1) not null,
DBSSet char(1) not null,
IBSSet char(1) not null,
TBSSet char(1) not null,
AOSSet char(1) not null,
DCSSet char(1) not null,
ICSSet char(1) not null,
DASSet char(1) not null,
IASSet char(1) not null,
TASSet char(1) not null
)
go
用存储过程做: //用于前台的某一事件
string ls_err
declare sp_01 procedure for qianqi1 ;
execute sp_01;
if sqlca.sqlcode=-1 then
ls_err=sqlca.sqlerrtext
rollback;
messagebox('','提示'+ls_err)
end if
close sp_01;
commit;
存储过程:
CREATE PROCEDURE [qianqi2] AS
if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tablename]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
create table tablename( aa char(10),
bb char(10)
)
GO
//有表不建立,无表建立 ,缺点是用户的不到无表时的提示信息。
if exists (select * from sysobjects where id = object_id(N'[dbo].[table_name]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[table_name]
GO