這是我正在使用的插入語句。此表中的主鍵是的IDNumber如何防止在SQL Server中重複的項不是主項字段
ALTER procedure [dbo].[AddCustomer]
@IDNumber nvarchar(20),
@Title nchar(10),
@Name nvarchar(50),
@Surname nvarchar(50),
@CellPhone nchar(10),
@AddressLine1 nvarchar(50),
@Suburb nvarchar(40),
@City nvarchar(30),
@PostalCode nchar(10),
@EmailAddress nvarchar(50),
@Password nvarchar(20)
as
insert into Customer(IDNumber,Title,Name,Surname,CellPhone,AddressLine1,Suburb,City,PostalCode,EmailAddress,[Password])
values (@IDNumber,@Title,@Name,@Surname,@CellPhone,@AddressLine1,@Suburb,@City,@PostalCode,@EmailAddress,@Password)
現在我想的SQL語句,將防止重複的電子郵件地址被插入。
[創建唯一索引(http://technet.microsoft.com/en-US/us-en/library/ms175132(v=sql.105).aspx) – bummi 2014-09-01 13:52:56