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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Generate DCN Nums

Author  Topic 

srinivasdasari
Starting Member

1 Post

Posted - 2010-09-18 : 01:58:16
Hi All,

Im not much of gud in sql.My question is how to generate data based on today date from 1 - 100 based on two conditions.
I mean My Sample Query Is
-- select 'EDI' + CONVERT(nvarchar(20),getdate(),112) + 'A00001' AS DCN_NO
Output is: EDI20100918A00001
same like up to EDI20100918A00100
condition 1:
if their is no data in my table.
condition 2:
if their is some data based on today date like EDI20100918A001 to EDI20100918A00100
take the max column from table and generate the data from that column.I mean EDI20100918A00101 - EDI20100918A00200


How to generate Through Query..Plz help me..

Regards
vasu


cnuvas

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-18 : 09:03:04
see

http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -