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
Set up a rolling text box in SSRS
Pass value on form through Querystring Javascript
Query a txt file and add a user account into administrator group of each machine.
split comma delimited values into seperate columns in SQL 2005
Problem with EFS Recovery
Windows 2008 DC and IP Default Gateway settings
Wireless AP network in a warehouse
Windows Server 2008 R2: missing start menu of installed applications
Ethernet crossover cable connect
Outlook 2010 bulk calendar delete