C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ADO.NET »

Concatenate the column with our format


Posted Date: 29 Oct 2008    Resource Type: Code Snippets    Category: ADO.NET
Author: Vinod ChattergeeMember Level: Silver    
Rating: 1 out of 5Points: 10



Sometimes we need concatenate the primary key with some other format, you can simply implement that using this snippet.
The output will be like this
if Primary Auto-Increment value is '1', then the out put will be FORMATSTRINGCOMESHERE001.




CREATE TABLE DEMOTABLE(DEMOIDCOLUMN INT IDENTITY PRIMARY KEY, DEMOCONCATIDCOLUMN AS 'FORMATSTRINGCOMESHERE'+RIGHT(1000+DEMOIDCOLUMN,3));-- YOU CAN SPECIFY THE FORMAT,LENGTH AND ALL IN THIS LINE

INSERT DEMOTABLE DEFAULT VALUES;

INSERT DEMOTABLE DEFAULT VALUES;

INSERT DEMOTABLE DEFAULT VALUES;

SELECT * FROM DEMOTABLE;
DROP TABLE DEMOTABLE



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Sql 2005  .  Concatenate string  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: MySql and Ado.Net
Previous Resource: PRITING DATATABLE
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use