Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi,How can i pre-formatted running number asYear(2 Char)Mth(2 Char)Type(2 Char)autonumber(6 char)if year & Mth not same, the autonumber will reset to be 1 again.Example:120101000001120101000002120101000003120201000001120202000002120302000001Please Advise.Thank you.
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-01-15 : 22:51:57
something like
SELECT RIGHT(DATENAME(yy,datefield),2) + RIGHT('00' + CAST(DATEPART(mm,datefield) AS varchar(2)),2) + Type + (1000000 + ROW_NUMBER() OVER (PARTITION BY YEAR(datefield),MONTH(datefiled) ORDER BY DAY(datefield))...
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/