我正在尝试
这是我到目前为止所做的:
--See if AuditActivities exists
IF OBJECT_ID('Audit') is not null
--here is where I need to see if either rows are null, if so, enter data
ELSE
CREATE TABLE [dbo].[Audit]
(
AuditSys int,
Description nvarchar(50)
);
答案 0 :(得分:0)
if exists (select * from [Audit])
begin
...
end
else
begin
...
end
答案 1 :(得分:0)
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Audit]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Audit]
(
AuditSys int,
Description nvarchar(50)
)
END
IF NOT EXISTS (SELECT * FROM [dbo].[Audit])
BEGIN
--INSERT here
END
答案 2 :(得分:0)
IF OBJECT_ID('Audit') is null
BEGIN
CREATE TABLE [dbo].[Audit]
(
AuditSys int,
Description nvarchar(50)
)
END
ELSE
IF exists(select * from Audit)
--insert some record
INSERT INTO Audit(COL1,COL2,..)
VALUES (VAL1,VAL2,...)