Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

MSSQL – Identity Insert

Posted on March 10, 2014June 15, 2017 By David Kittell
-- Attempt to insert an explicit ID value of 3;
-- should return a warning.
INSERT INTO products (id, product) VALUES(3, 'garden shovel')
GO
-- SET IDENTITY_INSERT to ON.
SET IDENTITY_INSERT products ON
GO

-- Attempt to insert an explicit ID value of 3
INSERT INTO products (id, product) VALUES(3, 'garden shovel').
GO

-- SET IDENTITY_INSERT to OFF
SET IDENTITY_INSERT products OFF
GO
-- SET IDENTITY_INSERT to ON.
SET IDENTITY_INSERT products ON
GO

-- Attempt to insert values from another table
INSERT INTO productsNEW (id, product)
SELECT (id, product) FROM products
GO

-- SET IDENTITY_INSERT to OFF
SET IDENTITY_INSERT products OFF
GO

Reference: http://technet.microsoft.com/en-us/library/aa259221(v=sql.80).aspx

Originally Posted on March 10, 2014
Last Updated on June 15, 2017
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code MSSQL SQL

Post navigation

Previous post
Next post

Related Posts

Exporting the Schema from the Source Forest

Posted on July 25, 2013October 26, 2015

The LDIFDE command-line tool, which ships with Windows Server 2003 and Windows Server 2008, can be used to export the schema from the source forest. This tool creates a file that is formatted with the LDAP Data Interchange Format (LDIF). No special permissions are required to export the schema from…

Read More

Write TXT File From textbox.text

Posted on May 13, 2013October 26, 2015

System.IO.File.WriteAllText(usertxt", txtbox.Text); Originally Posted on May 13, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is…

Read More

UNIX Terminal – Compare Directory On Different Servers

Posted on August 12, 2016

When working with two or more servers it’s important to know that the files are the same on all servers involved. This script will assist in showing the differences between the servers without actually acting on the differences (will not copy any files). Key part of the command below is…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes