C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Sequence in SQL Server


Posted Date: 26 Sep 2008    Resource Type: Code Snippets    Category: SQL

Posted By: @@@ Hyderabadi Biryani @@@       Member Level: Diamond
Rating:     Points: 10



This is to demonstrate how to create a table with IDENTITY Column.
let me give you some back ground on this. in Database world you need to have primary key to the table. Either Simple primary key or Composite Primary key.

SQL Server provides a feature which can be used to create a primary key for the table.



USE pubsIF EXISTS(
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'EMPLOYEE')
DROP TABLE EMPLOYEE

GO

CREATE TABLE EMP(emp_id int IDENTITY(10,2),emp_name varchar(50))



The above statement is used to create a table with Identity field.


INSERT INTO EMP (emp_name) VALUES ('Stephen')
INSERT INTO EMP (emp_name) VALUES ('Vince')

When you are inserting data into any table that has a IDENTITY column then then you need to skip that column in INSERT Clause.




Responses


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

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sequence in SQL Server  .  IDENTITY  .  

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: Pagination in SQL Server 2005
Previous Resource: Exception handing (TRY/CATCH) in SQL SERVER 2005
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing

Contact Us    Privacy Policy    Terms Of Use