SQL Table Identity change dynamically

Last Reply 4 days ago By dharmendr

Posted one month ago
CREATE TABLE [dbo].[Customers] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Customer] VARCHAR (MAX) NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);

Result:

1 Fahim

2 Ahmed

I need to change ID dynamically on each date change

201907170001 Fahim

201907170002 Ahmed

and when date change it should again start seeding but date will be changed

201907180001 Fahim

201907180002 Ahmed

Or is there any way to pass value from lable which will have date in this format 20190717

You are viewing reply posted by: fahimahmed 5 days ago.
Posted 5 days ago

i guess, DISTINCT has nothing to do in terms of saving duplicate record.

1. I'm counting daily Invoice against date (i.e. How many orders placed today).

2. I'm adding +1 and genrating Order # and saving in database.

 

Somehow, i'm getting duplicate invoice number. no idea why i'm facing this issue.