id,name,departmentid,idcard,creditDocNo,type
1,'王红',12,'522501198201153614',1,'A照'
2,'王红',12,'522501198201153614',1,'B照'
3,'张某',2,'522530195703022938',2,'E照'
4,'前红',3,'522501196207032013',3,'N照'
说明,我的ID是自动生成,我的要求限制是我一个departmentid下面,一个idcard只能有一个creditDocNo,这样的索引怎么写?CREATE UNIQUE INDEX [in_departmentid_creditDocNo] ON [dbo].[dt_career]([departmentID], [creditDocNo],[idcard]) ON [PRIMARY]
GO
我写的再个是提示错误的
------解决方案--------------------
- SQL code
--试试CREATE UNIQUE NONCLUSTERED INDEX [IX_tb3] ON [dbo].[tb] ( [departmentid] ASC, [idcard] ASC, [creditDocNo] ASC)WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
------解决方案--------------------
CREATE UNIQUE NONCLUSTERED INDEX [IX_tb3] ON [dbo].[dt_career]
(
[departmentid] ASC,
[idcard] ASC,
[creditDocNo] ASC
)
------解决方案--------------------
------解决方案--------------------