注意:1.tb_wx_userinfo已经存在,直接复制该表结构
DECLARE @manufacturer_id NVARCHAR(10),@sql NVARCHAR(500)
SET @manufacturer_id=10001
-- 创建微信用户信息分表
if not exists (select id from sysobjects where id = OBJECT_ID(‘[dbo].[tb_wx_userinfo_‘+ @manufacturer_id +‘]‘))
begin
set @sql = N‘select * into [dbo].[tb_wx_userinfo_‘+ @manufacturer_id +‘] from dbo.tb_wx_userinfo where 1 = 2;
alter table [dbo].[tb_wx_userinfo_‘+ @manufacturer_id +‘] add constraint PK_tb_wx_userinfo‘[email protected]_id+‘ primary key(wx_userinfo_id)‘
EXEC sp_executesql @sql
END
时间: 2024-10-27 10:57:05