标签:
注意: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‘+@manufacturer_id+‘ primary key(wx_userinfo_id)‘
EXEC sp_executesql @sql
END
标签:
原文地址:http://www.cnblogs.com/zhuyapeng/p/5652235.html