1.ALTER TABLE [DiskPackageRecord].[dbo].[InsiteData] ALTER COLUMN [CONTAINERNAME] nvarchar(255) NOT NULL
第一,确保要设主键的列不为空
2.ALTER TABLE [DiskPackageRecord].[dbo].[InsiteData] ADD PRIMARY KEY ([CONTAINERNAME]);
第二,设置主键列
SELECT top 10 *
FROM [DiskPackageRecord].[dbo].[InsiteData] where [CONTAINERNAME] in( select [CONTAINERNAME] FROM [DiskPackageRecord].[dbo].[InsiteData] group by [CONTAINERNAME] having count([CONTAINERNAME])>1)
检查要设主键的列有没有重复列