{"id":2190,"date":"2019-02-28T17:54:11","date_gmt":"2019-02-28T23:54:11","guid":{"rendered":"https:\/\/deepinthecode.com\/?p=2190"},"modified":"2022-12-20T17:25:55","modified_gmt":"2022-12-20T23:25:55","slug":"sql-server-script-to-create-insert-statements","status":"publish","type":"post","link":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/","title":{"rendered":"SQL Server Script to Create INSERT Statements"},"content":{"rendered":"\n<p>Though you can generate INSERT statements using SQL Server Management Services if the Generate Scripts functionality is enabled, this script may help in cases when it is not.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: sql; title: ; notranslate\" title=\"\">\nUSE DatabaseName\nGO\nSET NOCOUNT ON\n\nDECLARE @TableName VARCHAR(255)\nDECLARE @IndividualInserts BIT\n\nSET @TableName = 'TableName'\nSET @IndividualInserts = 0\n\nDECLARE @TableStructure TABLE (ColumnName VARCHAR(255), DataType VARCHAR(50), &#x5B;MaxLength] INT, &#x5B;precision] INT, &#x5B;scale] INT, is_nullable BIT, PrimaryKey BIT, ColumnID INT)\nDECLARE @ColumnName VARCHAR(255)\nDECLARE @DataType VARCHAR(50)\nDECLARE @MaxLength INT\nDECLARE @precision INT\nDECLARE @scale INT\nDECLARE @is_nullable BIT\nDECLARE @PrimaryKey BIT\nDECLARE @ColumnID INT\nDECLARE @SelectQuery VARCHAR(MAX) = ''\nDECLARE @ResultQuery VARCHAR(MAX) = ''\nDECLARE @SQL NVARCHAR(MAX) = ''\nDECLARE @CrLf VARCHAR(10) = CHAR(13) + CHAR(10)\n\nINSERT INTO @TableStructure\nSELECT \n    c.name 'Column Name',\n    t.Name 'Data type',\n    c.max_length 'Max Length',\n    c.precision ,\n    c.scale ,\n    c.is_nullable,\n    ISNULL(i.is_primary_key, 0) 'Primary Key',\n\tc.column_id\nFROM    \n    sys.columns c\nINNER JOIN \n    sys.types t ON c.user_type_id = t.user_type_id\nLEFT OUTER JOIN \n    sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id\nLEFT OUTER JOIN \n    sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id\nWHERE\n    c.object_id = OBJECT_ID(@TableName) \nORDER BY c.column_id\n\n--SELECT * FROM @TableStructure\n\nDECLARE TableCursor CURSOR FOR\nSELECT * FROM @TableStructure \nORDER BY ColumnID\n\n\nOPEN TableCursor\nFETCH NEXT FROM TableCursor INTO @ColumnName, @DataType, @MaxLength, @precision, @scale, @is_nullable, @PrimaryKey, @ColumnID\nWHILE @@FETCH_STATUS = 0\nBEGIN\n\t--SELECT @ColumnName, @DataType, @MaxLength, @precision, @scale, @is_nullable, @PrimaryKey, @ColumnID\n\tSET @ColumnName = '&#x5B;' + @ColumnName + ']'\n\tIF LEN(@SelectQuery)=0 SET @SelectQuery='SELECT' + @CrLf + '''INSERT INTO ' + @TableName + ' (' \n\tELSE SET @SelectQuery = @SelectQuery + ',' --@CrLf + ',' \n\tSET @SelectQuery = @SelectQuery + @ColumnName -- + '   -- ' + @DataType\n\n\tIF LEN(@ResultQuery)=0 \n\tBEGIN\n\t\tIF @IndividualInserts=0 SET @ResultQuery = 'UNION ALL SELECT CASE WHEN ROW_NUMBER() OVER(ORDER BY ' + @ColumnName + ') &amp;amp;amp;amp;amp;lt;&amp;amp;amp;amp;amp;gt; 1 THEN '','' ELSE '''' END +' + @CrLf + '''('\n\t\tELSE SET @ResultQuery= @CrLf + '(' \n\tEND\n\tELSE SET @ResultQuery = @ResultQuery + ','\n\tSELECT @ResultQuery = \n\tCASE\n\t\tWHEN @DataType LIKE '%CHAR' \n\t\tTHEN @ResultQuery + '''+ COALESCE('''''''' + ' + @ColumnName + ' + '''''''',''NULL'') +'''\n\t\tWHEN @DataType LIKE '%DATETIME' \n\t\tTHEN @ResultQuery + '''+ COALESCE(''CONVERT(DATETIME,'''''' + CONVERT(VARCHAR,' + @ColumnName + ',21) + '''''',21)'',''NULL'') +'''\t\t\n\t\tWHEN @DataType LIKE 'NUMERIC%' \n\t\tTHEN @ResultQuery + '''+ COALESCE(CONVERT(VARCHAR,' + @ColumnName + '),''NULL'') +'''\n\t\tWHEN @DataType = 'TEXT' \n\t\tTHEN @ResultQuery + '''+ COALESCE('''''''' + CONVERT(VARCHAR,' + @ColumnName + ') + '''''''',''NULL'') +'''\n\t\tWHEN @DataType LIKE '%INT' \n\t\tTHEN @ResultQuery + '''+ COALESCE(CONVERT(VARCHAR,' + @ColumnName + '),''NULL'') +'''\n\t\tWHEN @DataType = 'FLOAT' \n\t\tTHEN @ResultQuery + '''+ COALESCE(CONVERT(VARCHAR,' + @ColumnName + '),''NULL'') +'''\n\t\tELSE @ResultQuery + '''+ COALESCE(' + @ColumnName + ',''NULL'') +'''\n\tEND\n\t--SET @ResultQuery = @ResultQuery + '   -- ' + @DataType\t\n\t\n\tFETCH NEXT FROM TableCursor INTO @ColumnName, @DataType, @MaxLength, @precision, @scale, @is_nullable, @PrimaryKey, @ColumnID\nEND\nCLOSE TableCursor\nDEALLOCATE TableCursor\n\nSET @SelectQuery = @SelectQuery + ') VALUES' \nIF @IndividualInserts=0 SET @SelectQuery = @SelectQuery + ''''\nSET @ResultQuery = @ResultQuery + ')'' FROM ' + @TableName + ';'\n\nSET @SQL = @SelectQuery + @ResultQuery\n\n--SELECT @SelectQuery\n--SELECT @ResultQuery\n\n--SELECT @SQL\n\n--PRINT @SelectQuery \n--PRINT @ResultQuery\nEXEC sp_executesql @SQL\n<\/pre><\/div>\n\n\n<p>This script may not work in every single case, as there are data types not accounted for here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Though you can generate INSERT statements using SQL Server Management Services if the Generate Scripts functionality is enabled, this script may help in cases when it is not. This script may not work in every single case, as there are data types not accounted for here.<\/p>\n","protected":false},"author":7,"featured_media":2186,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"SQL Server Script to Create INSERT Statements - #sql #adhoc","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12],"tags":[192,254],"class_list":["post-2190","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ms-sql-server","tag-sql-server","tag-transact-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server Script to Create INSERT Statements - Deep in the Code<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server Script to Create INSERT Statements - Deep in the Code\" \/>\n<meta property=\"og:description\" content=\"Though you can generate INSERT statements using SQL Server Management Services if the Generate Scripts functionality is enabled, this script may help in cases when it is not. This script may not work in every single case, as there are data types not accounted for here.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/\" \/>\n<meta property=\"og:site_name\" content=\"Deep in the Code\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/deepinthecode\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/deepinthecode\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-28T23:54:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-12-20T23:25:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/deepinthecode.com\/wp-content\/uploads\/2019\/01\/sqlserverlogo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1284\" \/>\n\t<meta property=\"og:image:height\" content=\"327\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"David Young\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@deepinthecode\" \/>\n<meta name=\"twitter:site\" content=\"@deepinthecode\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"David Young\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/\"},\"author\":{\"name\":\"David Young\",\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/#\\\/schema\\\/person\\\/2d8883371cb9a0d1d86ad28246d1b514\"},\"headline\":\"SQL Server Script to Create INSERT Statements\",\"datePublished\":\"2019-02-28T23:54:11+00:00\",\"dateModified\":\"2022-12-20T23:25:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/\"},\"wordCount\":53,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/#\\\/schema\\\/person\\\/2d8883371cb9a0d1d86ad28246d1b514\"},\"image\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/sqlserverlogo.png?fit=1284%2C327&ssl=1\",\"keywords\":[\"SQL Server\",\"Transact-SQL\"],\"articleSection\":[\"MS SQL Server\"],\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/\",\"url\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/\",\"name\":\"SQL Server Script to Create INSERT Statements - Deep in the Code\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/sqlserverlogo.png?fit=1284%2C327&ssl=1\",\"datePublished\":\"2019-02-28T23:54:11+00:00\",\"dateModified\":\"2022-12-20T23:25:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/sqlserverlogo.png?fit=1284%2C327&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2019\\\/01\\\/sqlserverlogo.png?fit=1284%2C327&ssl=1\",\"width\":1284,\"height\":327,\"caption\":\"Microsoft SQL Server logo\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/2019\\\/02\\\/28\\\/sql-server-script-to-create-insert-statements\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/deepinthecode.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Script to Create INSERT Statements\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/#website\",\"url\":\"https:\\\/\\\/deepinthecode.com\\\/\",\"name\":\"Deep in the Code\",\"description\":\"Adventures in Software Development ... by David Young\",\"publisher\":{\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/#\\\/schema\\\/person\\\/2d8883371cb9a0d1d86ad28246d1b514\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/deepinthecode.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/deepinthecode.com\\\/#\\\/schema\\\/person\\\/2d8883371cb9a0d1d86ad28246d1b514\",\"name\":\"David Young\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/monolith2.png?fit=902%2C559&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/monolith2.png?fit=902%2C559&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/monolith2.png?fit=902%2C559&ssl=1\",\"width\":902,\"height\":559,\"caption\":\"David Young\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/deepinthecode.com\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/monolith2.png?fit=902%2C559&ssl=1\"},\"description\":\"I solve problems. Solutions Architect \\\/ Senior Software Engineer \\\/ Business Analyst \\\/ Full-Stack Developer \\\/ Data Scientist\\\/ IT Generalist\",\"sameAs\":[\"https:\\\/\\\/deepinthecode.com\",\"https:\\\/\\\/facebook.com\\\/deepinthecode\",\"https:\\\/\\\/instagram.com\\\/deepinthecode\",\"https:\\\/\\\/linkedin.com\\\/in\\\/deepinthecode\",\"https:\\\/\\\/x.com\\\/deepinthecode\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server Script to Create INSERT Statements - Deep in the Code","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server Script to Create INSERT Statements - Deep in the Code","og_description":"Though you can generate INSERT statements using SQL Server Management Services if the Generate Scripts functionality is enabled, this script may help in cases when it is not. This script may not work in every single case, as there are data types not accounted for here.","og_url":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/","og_site_name":"Deep in the Code","article_publisher":"https:\/\/facebook.com\/deepinthecode","article_author":"https:\/\/facebook.com\/deepinthecode","article_published_time":"2019-02-28T23:54:11+00:00","article_modified_time":"2022-12-20T23:25:55+00:00","og_image":[{"width":1284,"height":327,"url":"https:\/\/deepinthecode.com\/wp-content\/uploads\/2019\/01\/sqlserverlogo.png","type":"image\/png"}],"author":"David Young","twitter_card":"summary_large_image","twitter_creator":"@deepinthecode","twitter_site":"@deepinthecode","twitter_misc":{"Written by":"David Young","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#article","isPartOf":{"@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/"},"author":{"name":"David Young","@id":"https:\/\/deepinthecode.com\/#\/schema\/person\/2d8883371cb9a0d1d86ad28246d1b514"},"headline":"SQL Server Script to Create INSERT Statements","datePublished":"2019-02-28T23:54:11+00:00","dateModified":"2022-12-20T23:25:55+00:00","mainEntityOfPage":{"@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/"},"wordCount":53,"commentCount":0,"publisher":{"@id":"https:\/\/deepinthecode.com\/#\/schema\/person\/2d8883371cb9a0d1d86ad28246d1b514"},"image":{"@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2019\/01\/sqlserverlogo.png?fit=1284%2C327&ssl=1","keywords":["SQL Server","Transact-SQL"],"articleSection":["MS SQL Server"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/","url":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/","name":"SQL Server Script to Create INSERT Statements - Deep in the Code","isPartOf":{"@id":"https:\/\/deepinthecode.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#primaryimage"},"image":{"@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2019\/01\/sqlserverlogo.png?fit=1284%2C327&ssl=1","datePublished":"2019-02-28T23:54:11+00:00","dateModified":"2022-12-20T23:25:55+00:00","breadcrumb":{"@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#primaryimage","url":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2019\/01\/sqlserverlogo.png?fit=1284%2C327&ssl=1","contentUrl":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2019\/01\/sqlserverlogo.png?fit=1284%2C327&ssl=1","width":1284,"height":327,"caption":"Microsoft SQL Server logo"},{"@type":"BreadcrumbList","@id":"https:\/\/deepinthecode.com\/2019\/02\/28\/sql-server-script-to-create-insert-statements\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/deepinthecode.com\/"},{"@type":"ListItem","position":2,"name":"SQL Server Script to Create INSERT Statements"}]},{"@type":"WebSite","@id":"https:\/\/deepinthecode.com\/#website","url":"https:\/\/deepinthecode.com\/","name":"Deep in the Code","description":"Adventures in Software Development ... by David Young","publisher":{"@id":"https:\/\/deepinthecode.com\/#\/schema\/person\/2d8883371cb9a0d1d86ad28246d1b514"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/deepinthecode.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":["Person","Organization"],"@id":"https:\/\/deepinthecode.com\/#\/schema\/person\/2d8883371cb9a0d1d86ad28246d1b514","name":"David Young","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/07\/monolith2.png?fit=902%2C559&ssl=1","url":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/07\/monolith2.png?fit=902%2C559&ssl=1","contentUrl":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/07\/monolith2.png?fit=902%2C559&ssl=1","width":902,"height":559,"caption":"David Young"},"logo":{"@id":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/07\/monolith2.png?fit=902%2C559&ssl=1"},"description":"I solve problems. Solutions Architect \/ Senior Software Engineer \/ Business Analyst \/ Full-Stack Developer \/ Data Scientist\/ IT Generalist","sameAs":["https:\/\/deepinthecode.com","https:\/\/facebook.com\/deepinthecode","https:\/\/instagram.com\/deepinthecode","https:\/\/linkedin.com\/in\/deepinthecode","https:\/\/x.com\/deepinthecode"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2019\/01\/sqlserverlogo.png?fit=1284%2C327&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3J1Ni-zk","jetpack-related-posts":[{"id":1366,"url":"https:\/\/deepinthecode.com\/2016\/10\/10\/sql-script-to-find-text-in-all-database-tables-and-viewsrevised-again\/","url_meta":{"origin":2190,"position":0},"title":"SQL Script to Find Text in all Database Tables and Views\u2026Revised! Again!","author":"David Young","date":"2016.10.10","format":false,"excerpt":"The SQL script below, which modifies one I wrote last year, has been modified to work with SQL Server 2008 and newer versions. On these versions, when querying SQL Server to output the schema of a database table, length values of MAX are returned as -1. Since this script builds\u2026","rel":"","context":"In &quot;MS SQL Server&quot;","block_context":{"text":"MS SQL Server","link":"https:\/\/deepinthecode.com\/category\/ms-sql-server\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":927,"url":"https:\/\/deepinthecode.com\/2015\/06\/25\/sql-script-to-find-text-in-all-database-tables-and-views-revised\/","url_meta":{"origin":2190,"position":1},"title":"SQL Script to Find Text in all Database Tables and Views&#8230;Revised!","author":"David Young","date":"2015.06.25","format":false,"excerpt":"Almost a year ago, I had reason to write a SQL script that would search for text anywhere in a database. Since then, I've had reason to modify and enhance it. The modification was done primarily to support SQL Server 2000, which I still have to support. The enhancement was\u2026","rel":"","context":"In &quot;MS SQL Server&quot;","block_context":{"text":"MS SQL Server","link":"https:\/\/deepinthecode.com\/category\/ms-sql-server\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":760,"url":"https:\/\/deepinthecode.com\/2014\/07\/10\/sql-script-find-text-database-tables-views\/","url_meta":{"origin":2190,"position":2},"title":"SQL Script to Find Text in all Database Tables and Views","author":"David Young","date":"2014.07.10","format":false,"excerpt":"I get new applications to work on fairly regularly, and I have found that almost none of them have databases that are normalized to the third normal form. (Shocking, I know.) One that I recently inherited appears to store email addresses in multiple tables instead of in a single table\u2026","rel":"","context":"In &quot;MS SQL Server&quot;","block_context":{"text":"MS SQL Server","link":"https:\/\/deepinthecode.com\/category\/ms-sql-server\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":229,"url":"https:\/\/deepinthecode.com\/2013\/04\/03\/moving-data-from-the-image-datatype-to-varbinarymax-from-a-sql-server-2000-instance\/","url_meta":{"origin":2190,"position":3},"title":"Moving Data from the IMAGE Datatype to VARBINARY(MAX) from a SQL Server 2000 Instance","author":"David Young","date":"2013.04.03","format":false,"excerpt":"I am in the process of writing scripts to move data from a SQL 2000 database into a different database running on SQL 2008. I had set up a linked server from the SQL 2k server to begin this process, and about 90% of the data could be moved. \u00a0One\u2026","rel":"","context":"In &quot;MS SQL Server&quot;","block_context":{"text":"MS SQL Server","link":"https:\/\/deepinthecode.com\/category\/ms-sql-server\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2633,"url":"https:\/\/deepinthecode.com\/2022\/06\/27\/testing-connectivity-to-multiple-sql-server-linked-servers\/","url_meta":{"origin":2190,"position":4},"title":"Testing Connectivity to Multiple SQL Server Linked Servers","author":"David Young","date":"2022.06.27","format":false,"excerpt":"As we are preparing to migrate some of our older SQL Server databases that are nearing their end of support to SQL Server 2019, one of the necessary tasks is determining what Linked Servers need to be established on the new servers to maintain the existing functionality for all of\u2026","rel":"","context":"In &quot;MS SQL Server&quot;","block_context":{"text":"MS SQL Server","link":"https:\/\/deepinthecode.com\/category\/ms-sql-server\/"},"img":{"alt_text":"SQL Server 2022","src":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/06\/sqlserver2022.png?fit=1007%2C600&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/06\/sqlserver2022.png?fit=1007%2C600&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/06\/sqlserver2022.png?fit=1007%2C600&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2022\/06\/sqlserver2022.png?fit=1007%2C600&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1890,"url":"https:\/\/deepinthecode.com\/2018\/04\/20\/comparing-multiple-patterns-with-like-operator\/","url_meta":{"origin":2190,"position":5},"title":"Comparing Multiple Patterns with LIKE Operator","author":"David Young","date":"2018.04.20","format":false,"excerpt":"I really like the LIKE operator! (See what I did there?) I use it on a daily basis. It does have one frustrating shortcoming, however. Unlike the IN operator (where a list is used for comparison), you can only compare one pattern with each LIKE statement. If you have only\u2026","rel":"","context":"In &quot;MS SQL Server&quot;","block_context":{"text":"MS SQL Server","link":"https:\/\/deepinthecode.com\/category\/ms-sql-server\/"},"img":{"alt_text":"pic of Facebook Like button","src":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2018\/04\/LIKE.png?fit=1126%2C546&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2018\/04\/LIKE.png?fit=1126%2C546&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2018\/04\/LIKE.png?fit=1126%2C546&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2018\/04\/LIKE.png?fit=1126%2C546&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/deepinthecode.com\/wp-content\/uploads\/2018\/04\/LIKE.png?fit=1126%2C546&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/posts\/2190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/comments?post=2190"}],"version-history":[{"count":9,"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/posts\/2190\/revisions"}],"predecessor-version":[{"id":3211,"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/posts\/2190\/revisions\/3211"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/media\/2186"}],"wp:attachment":[{"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/media?parent=2190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/categories?post=2190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deepinthecode.com\/wp-json\/wp\/v2\/tags?post=2190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}