Blog Post

Generating scripts for previous versions of SQL

,

I make a habit of using the latest version of SSMS even if I’m not working with the latest version of SQL Server. For example right now at home I’m using SSMS 2016 even though I frequently work with SQL Server 2014 or 2012. Well this can cause a bit of a problem when I’m using the script button to generate scripts of changes I make in the GUI. With each version some of the commands change, some of the settings change, etc. This means that when I script out something with my latest version of SSMS I’m getting the latest version of the code. Not good if I’m trying to run that script on the older version of SQL.

For example when I scripted out a database it started with this:

CREATE DATABASE [Test]
 CONTAINMENT = NONE
 ON  PRIMARY 
 ....

Run that on a 2005 instance, I dare you šŸ™‚. Contained databases weren’t introduced until SQL 2012, so this script won’t run on 2008 or 2008 R2 databases either. So what’s the solution? Change one of the scripting settings!

OldScripting1

Now when I run the same script I get this:

CREATE DATABASE [Test] ON  PRIMARY 
....

And there we go. A 2005 version of the same script.

Note: this scripting option is also available in the Generate scripts advanced scripting options.

OldScripting2

OldScripting3

Filed under: Microsoft SQL Server, Settings, SQLServerPedia Syndication, SSMS, T-SQL Tagged: microsoft sql server, script button, Scripting, SSMS, T-SQL

Rate

ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜…

You rated this post out of 5. Change rating

Share

Share

Rate

ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜… ā˜…

You rated this post out of 5. Change rating