注意: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

相关文章:

  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-02-21
  • 2021-10-10
  • 2021-12-31
  • 2022-01-08
  • 2021-12-04
猜你喜欢
  • 2022-12-23
  • 2021-07-25
  • 2021-12-07
  • 2022-01-02
  • 2021-08-17
  • 2022-12-23
相关资源
相似解决方案