CREATE PROCEDURE upMyProcedure
(
@MyTableName NVarChar(255)
)
AS
if object_id(@mytablename) is not null
beign
...
end
else
exec('create table '+@mytablename+' (a int)')
GO
(
@MyTableName NVarChar(255)
)
AS
if object_id(@mytablename) is not null
beign
...
end
else
exec('create table '+@mytablename+' (a int)')
GO
You're great!
Thank you very much!这个文件大家也可以参考一下:
X:\Program Files\Microsoft SQL Server\mssql\Install\replmerg.sql不知可否再问大家一句:
pengdali(大力)写的 if object_id(@mytablename) is not null 可以用来检测表是否存在,但
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[@mytablename]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
好像不行,为什么呢?24小时内结贴.
GO