declare @ii int
set @ii = 0
while @ii <= 50
begin
declare @strSql varchar(500) ,@str varchar(500) ,@strIndexSql varchar(500)
set @str = @ii
set @strSql = 'create table dbo.test_'+ @str + '(logGid uniqueidentifier NOT NULL,
user_gid uniqueidentifier NOT NULL,
create_time datetime NOT NULL,
data_version nvarchar(64) NOT NULL,
rule_id varchar(64) NOT NULL,
rule_value decimal(30, 4) NOT NULL,
rule_v nvarchar(1024) NULL,
remark nvarchar(1024) NULL,
IDCardNO varchar(32) NOT NULL DEFAULT ('''+ '''),
share_type tinyint NOT NULL DEFAULT (0),
channel varchar(32) NOT NULL DEFAULT ('''+'''))'
execute(@strSql)
set @strIndexSql = '
CREATE UNIQUE NONCLUSTERED INDEX ix_test_'+@str +'_usergid_ruleid ON dbo.test_'+@str +'
(
user_gid ASC,
rule_id ASC
) '
execute(@strIndexSql)
set @strIndexSql = '
CREATE NONCLUSTERED INDEX ix_test_'+@str +'_create_time ON dbo.test_'+@str +'
(
create_time ASC
) '
execute(@strIndexSql)
Set @ii = @ii+1
end