F
fniles
I have a SQL Server 2005 table with an Identity column called ID, a
Primary Key column called [Order], and an Account column like this:
CREATE TABLE [dbo].[HistTradesOrig](
[ID] [int] IDENTITY(1,1) NOT NULL,
[order] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL,
[Account] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL
CONSTRAINT [DF_HistTradesOrig_Bill] DEFAULT ('0'),
CONSTRAINT [PK__HistTradesOrig__52593CB8] PRIMARY KEY CLUSTERED
(
[order] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
I need to set [Order] to be a unique number containing account and
another 6 digits number.
Currently, most times I set [Order] = @ACCOUNT + '-' +
convert(varchar(50),@ID) where @ID is the SCOPE_IDENTITY().
Currently, this 6 digits number ranges from 100,000 to 999,999, and if
it's possible we would like to keep it that way.
The problem with that is since I have multiple thread doing it, every
now and then I get Transaction Lock error.
1. Is there any other way for me to set [Order] to be Account +
another unique 6 digits number besides getting it from the Identity
column of the same table ?
2. Is there a VB.NET subroutine/function that I can call to create a 6
digit unique number (so that I don't have to depend on the identity
column of that table) ?
Thank you.
Primary Key column called [Order], and an Account column like this:
CREATE TABLE [dbo].[HistTradesOrig](
[ID] [int] IDENTITY(1,1) NOT NULL,
[order] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
NULL,
[Account] [varchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS
NULL
CONSTRAINT [DF_HistTradesOrig_Bill] DEFAULT ('0'),
CONSTRAINT [PK__HistTradesOrig__52593CB8] PRIMARY KEY CLUSTERED
(
[order] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
I need to set [Order] to be a unique number containing account and
another 6 digits number.
Currently, most times I set [Order] = @ACCOUNT + '-' +
convert(varchar(50),@ID) where @ID is the SCOPE_IDENTITY().
Currently, this 6 digits number ranges from 100,000 to 999,999, and if
it's possible we would like to keep it that way.
The problem with that is since I have multiple thread doing it, every
now and then I get Transaction Lock error.
1. Is there any other way for me to set [Order] to be Account +
another unique 6 digits number besides getting it from the Identity
column of the same table ?
2. Is there a VB.NET subroutine/function that I can call to create a 6
digit unique number (so that I don't have to depend on the identity
column of that table) ?
Thank you.