Solved

Existing Table - Column id --> Primary Key - Want to add value -->0

Posted on 2011-09-06
4
174 Views
Last Modified: 2012-05-12
I have an existing table with CrewID as the Primary Key.  I want to add a crew (<-- Unknown Crew -->) with a CrewID = 0.

Any help is greatly appreciated
LJG
0
Comment
Question by:LJG
  • 2
4 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 36490157
You mean you want to explicitly set the ID. Is it an IDENTITY column?
0
 
LVL 8

Accepted Solution

by:
stalhw earned 500 total points
ID: 36490226
just do:
SET IDENTITY INSERT ON
INSERT INTO CrewID (id, name) VALUES (0,'Unknown')
SET IDENTITY INSERT OFF
0
 
LVL 2

Author Comment

by:LJG
ID: 36490541
Stalhw
Thanks so much - it solved my problem.  

(FYI: Works perfect - but by the way I had to use identity_Insert with an underline between the two words)
0
 
LVL 8

Expert Comment

by:stalhw
ID: 36490585
oh yeah sorry forgot the _
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question