Microsoft
Software
Hardware
Network
Question : sql column that represents a unique tag number
We have a table with a column that represents a unique tag number [INumber]. We created a CREATE UNIQUE NONCLUSTERED INDEX on it and we want to add a contraint that will take the identify column as its default value. How can we do this?
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ATable]
') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ATable]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ATable](
[ID] [int] IDENTITY(1,1) NOT NULL,
[IName] [nvarchar](500) NOT NULL,
[INumber] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_ATable] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[ATable] WITH NOCHECK ADD
CONSTRAINT [DF_ATable_IName] DEFAULT ('') FOR [IName]
GO
CREATE UNIQUE NONCLUSTERED INDEX [UIX_ATable_INumber] ON [dbo].[ATable]([INumber]) ON [PRIMARY]
GO
Answer : sql column that represents a unique tag number
You could use a TRIGGER for INSERT that updated this field to value of ID if it is NULL.
Random Solutions
PPT Taskkill Command VBS MsgBox
CVV2 checker for C# code
dell powervault ejection issues
Multi Homed Windows 2008 Server
IE version confusion.
PHP Email
OnPopup + sql query
Win7/XP Encrypted file - won't let me open
Change Mac disk to from case-sensitive, Journaled to Case-insensitive, Journaled.
FM Pro - Multiple Questions Open - 1 issue!!: Best Way to Calculate and Filter