Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to generate auto increment column value in stored procedure and passing the parameter to the like('A',string length,table name,table id) from the front end and generate A000,A001,A002,...like that ,if we change front end parameter (B,4,tname,idname) it generate like B000,B001,B002,...like that ( send the code to perform this in stored procedure)
Posted
Updated 25-May-11 1:48am
v3
Comments
ZeeroC00l 25-May-11 7:49am    
-- edited for typo
Manfred Rudolf Bihy 25-May-11 8:46am    
"Send the code ..."
No!

This great article should give you a couple of ideas: http://www.sqlteam.com/article/custom-auto-generated-sequences-with-sql-server[^].

Cheers!

-MRB
 
Share this answer
 
To generate auto increment column you can simply use the RANK methods available in SQL Server,
i believe ROW_NUMBER (Transact-SQL) rank methods will help you in this case to generate auto number column.

Link: ROW_NUMBER (Transact-SQL)

The Recursive Queries also give you an option to loop with in the rowset and generate auto increment column.

Link: Recursive Queries Using Common Table Expressions
 
Share this answer
 
Comments
RaviRanjanKr 27-May-11 7:50am    
Nice Answer, My 5 :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900