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 – Data Transfer

Posted on March 10, 2014October 26, 2015 By David Kittell

Recently I had to transfer ICD9CM codes from one database to another with limited database permissions, I decided to let the database work for me to perform the task.

Ideally you’d have Visual Studio SSIS or some other mass data transfer option but this query will help you to get the data across.

One thing to point out is the replace command for [shortdesc] and [desc], this replace command is helpful if your varchar data type fields have a single quote in them.

SET IDENTITY_INSERT icd9cm ON
GO
SELECT 'INSERT INTO icd9cm (id, name) VALUES (''' AS insert1
	,[id]
	,''',''' AS insert2
	,[group_id]
	,''',''' AS insert3
	,[pricode]
	,''',''' AS insert4
	,[seccode]
	,''',''' AS insert5
	,[code]
	,''',''' AS insert6
	,REPLACE([shortdesc], '''', '''''')
	,''',''' AS insert7
	,REPLACE([desc], '''', '''''')
	,''');' AS insert8
FROM [icd9cm]
Originally Posted on March 10, 2014
Last 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 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

Post navigation

Previous post
Next post

Related Posts

Distinct Query On One Column

Posted on May 20, 2014October 26, 2015

While this query has more than what may be needed this will help you to get data based on one unique column. SELECT [File Name] ,[Division] ,[Version] FROM ( SELECT [File Name] ,[Division] ,[Version] ,row_number() OVER ( PARTITION BY [Division] ORDER BY [Version] DESC ) AS RowNumber FROM <DatabaseTableName> )…

Read More

Get Number Of Rows Deleted

Posted on August 1, 2013October 26, 2015

DELETE FROM Files WHERE FileID = 1 SELECT @@ROWCOUNT AS DELETED; Originally Posted on August 1, 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…

Read More

SQL – Log Parser Studio – User-Agent

Posted on December 4, 2015December 4, 2015

Caution: These scripts will take some time to run on large logs. /* List Browser types used */ SELECT DISTINCT CASE strcnt(cs(user – agent), ‘Chrome’) WHEN 1 THEN ‘Chrome’ ELSE CASE strcnt(cs(user – agent), ‘Firefox’) WHEN 1 THEN ‘Firefox’ ELSE CASE strcnt(cs(user – agent), ‘MSIE+6’) WHEN 1 THEN ‘IE 6’…

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