USE [ARC_DB]
GO
/****** Object: StoredProcedure [dbo].[SP_CreateTable_ArcRecord] Script Date: 2021/1/25 14:57:05 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SP_CreateTable_ArcRecord]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
ALTER PROCEDURE [dbo].[SP_CreateTable_ArcRecord]
AS
BEGIN
--设置年
declare @year varchar(10);
set @year = CONVERT(varchar(4), GETDATE(), 23);
declare @tbName varchar(60);
set @tbName = ''ARC_RECORD_'' + @year;
DECLARE @Sql VARCHAR(MAX) = ''
IF OBJECT_ID(''''[dbo].[''+@tbName+'']'''') IS NULL
BEGIN
CREATE TABLE [dbo].[''+@tbName+'']
(
[ID] [varchar](36) NOT NULL,
[ARC_LOG_ID] [nvarchar](36) NULL,
[ARC_PATH] [nvarchar](500) NULL,
[ARC_TIME] [datetime] NULL,
[SERIAL_NUMBER] [nvarchar](50) NULL,
[TASK_ID] [nvarchar](36) NULL,
[LICENSE_PLATE_NUMBER] [nvarchar](50) NULL,
)
END
''
EXEC(@Sql)
END
'
END
网友评论