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
School Network
Excel VBA
Custom drupal searchbox
HTML and opening new pages, can the following be done?
How do I get the value Member from a Multi-select List box in VB.NET
Problems Installing PyQt on OS X 10.6.3
Help! Terminal Server printing
sendAndLoad onHTTPStatus issue
how to install certificate in SBS 2008
How to create a self signed certificate on windows XP