Create Database in SQL Server 2012, Script and Use in 2008? - sql-server-2008

If I create a database using 2012 and work and add that info to it, if I were to script the database after, would I be able to run the script in 2008 and have everything work A.O.K?

If you are using SQL Management Studio, you can right-click on the database name, then select Tasks → Generate Scripts.
Here you will be able to create scripts to script out the Schema, Data, or both Schema and Data, and if you click the Advanced button, you can specify which version of SQL Server you'd like to target.
So, simply choose SQL 2008 as the destination server and you should be good to go!

A script? Yes. Well, let me rephrase: it depends. As long as your objects don't use any 2012-specific features, you will be able to script out the schema using Management Studio or a variety of 3rd party tools (I blogged about some options here). Many of the tools also offer options (or companion tools) to also script the data.
The problem is there isn't a very easy way in SQL Server 2012 to identify all of the places where you might be using 2012-specific features. For example, I don't know of a tool that will inspect your database and point out that you are using the FORMAT() function, which is not available in SQL Server 2008 or 2008 R2.
Other means of copying the database over - backup/restore, attach/detach, mirroring/log shipping etc. will not work. You can go up (from 2005, 2008 or 2008 R2) to 2012, but you can't go backwards.
So in general I agree with John. Much safer to develop on a version <= deployment version. Why would you want to develop on 2012 to deploy to 2008? Seems quite risky to me.

If you have very large amounts of data to move (gigabytes) then the TSQL scripts that the SQL Management Studio will generate for you could give you problems because of the sheer size. A better alternative would be to use BCP (Bulk Copy Program). The downside is that this is a command line utility and requires more work than just using the wizard.
As luck would have it somebody has written something which looks remarkably like the wizard only using BCP. It is the SQL Database Migration Wizard and is freely available on Codeplex - http://sqlazuremw.codeplex.com/releases/view/32334. Originally intended as a database migration tool between SQL Server and Azure you can just as easily use it between SQL Server and SQL Server. The key is to go into the advanced options (similar to the Management Studio wizard) and pick SQL Server. Later when you are prompted for the target system choose your 2008 installation.
I had no 2012 specific artefacts in my database and it worked very smoothly for me.

Related

Reporting Services Built in 2012 Deploy in 2008

I have been working for a client who run SQL Server 2008 in their live environment. I had been working onsite for a period but now work from home. However, due to security, I cannot connect to the live setup, I can only connect to a test server. This server runs SQL Server 2012. I script any code and send it to the office for someone to deploy. The problem I have is I am now doing some reporting services work. They are only pretty basic reports, tablix controls, nothing fancy. Is is possible to build on 2012 and deploy to 2008? Can I do something with the .rdl file to make this work or is it not going to be feasible?
Thanks in advance
In the Properties of the ReportServer Project in Visual Studio you can set the target server version.
Right click the Project in the Solution Explorer pane and set the TargetServerVersion Property to the required version. This works for reports SQL Server Reporting Services 2008 onwards. The designer will then manage what features are available to avoid using features from a later version of SSRS.
The .rdl files are nicely formated XML. You can use your favorite diff tool to compare reports generated in either version of the tool.
I'm pretty sure that Microsoft doesn't support moving a newer RDL to an older version server.
There were huge changes to the .rdl format between 2005 and 2008, moderate changes between 2008 and 2008R2, but I haven't really looked into 2008R2 versus 2012. From what I've seen these should be smaller changes yet.
If you do this you are off of the golden supported brick road. Since this server is production, and you don't have a good way to test this, I would find a 2008 server to develop with. I wouldn't want my name connected with the possible problems that could come up with a hack to move the rdl backwards.

What tools do I need to create an SSIS package in SQL Server 2008 Express?

On my development machine I have Visual Studio 2010 and SQL Server 2008 Express. On our production server we have SQL Server 2008 Standard. I am going to create a WCF service that will reside on the production SQL server that will fire my SSIS package when called.
Because I have SQL Express on my development machine, I do not have access to create SSIS packages from this machine at all. This is needed so I can write the WCF service in the first place.
So, I could simply download SQL Server 2008 Standard from our msdn subscription to my development machine, but for reasons I cannot get into, this is not immediately possible. It will be in the near future but not soon enough.
How can I get this done? Are there tools to download? Where? I have researched this at length but there appears to be 5 different ways that lead to no where.
Since you have a licensed Edition of SQL Server on your network you can install the full suite of tools on your development server or your own desktop if you wish. This will give you access to BIDS software that SliverNinja mentioned.
I would say since you are limited to what can be done you only option would be to deploy a simple/basic package to your production server. If your development server can communicate with that server, I would say create your WCF service on the development box and have it simply call the package on your production server. The package does not have to do anything fancy to simply verify that you can call it correctly. Just have the package import a simple file and output it to a different file; or just export some catalog data from a database.
I do not see, since you are limited by not being able to duplicate your production environment on your dev server, that this would be unreasonable to do in this situation. If it has to get done, it has to get done.
So you want to create a package without BIDS?
Feel free to create one using plain text, there you go :)
<DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts" DTS:ExecutableType="MSDTS.Package.1">
<DTS:Property DTS:Name="PackageFormatVersion">2</DTS:Property>
<DTS:Property DTS:Name="CreationDate" DTS:DataType="7">5/18/2012 1:21:47 PM</DTS:Property>
<DTS:Property DTS:Name="ProtectionLevel">1</DTS:Property>
<DTS:Property DTS:Name="DisableEventHandlers">0</DTS:Property>
.....a lot more properties.....
</DTS:Executable>
I'm joking, of course. My points are:
dtsx packages are merely XML files created by BIDS
you can create your package anywere, if you cant use your local box,
use what you have, even if that means to use your server (if that's
your only option, do it)
you dont need BIDS or even the SSIS service to run pacakges. DTEXEC,
DTEXECUI and SQl Server Agent are capable of running packages by
themselves (unless the packages are deployed to the package store)
I am not aware of any tool that builds packages other than BIDS. It
wouldn't make much sense, is like asking if there is a tool where you
can build C# application other than visual studio
You need BIDS (Business Intelligence Development Studio) to create the DTSX packages and SSIS which isn't available with SQL Express.
You also need Visual Studio to create WCF services, which it sounds like you already have.

Can I make SQL 2008 Management Studio validate code for SQL 2005?

We have a production database running on SQL 2005. We are using SQL 2008 Management Studio. The issue we are having is that some of the stored procedures/functions we write get code that is compatible with SQL 2008, but not with SQL 2005. The newer management studio doesn't flag this as an error, but when we try to deploy a version, we get a large amount of errors. Is there any way to get 2008 Management Studio to validate code for compatibility?
Thanks!
Even if you are using Management Studio 2008, you dev database should match the prod one. It is an extremely poor idea to develop against a 2008 databse when your prod database is 2005. You can still hook to 2005 databases in management studio 2008. Then you will find out immediately that the code doesn't work. In fact if you are attached to a 2005 database, it will only let you use 2005 syntax. We attached to 2000 database for a long time until we got all the servers upgraded and it wouldn't let us write 2008 specific code as long as the database we attached to was 2000.
If, for some reason (and I stringly recommend against it), you will continue to develop against a 2008 database, I also suggest you look in Book Online for the new features of 2008 and make sure all your devs know which features they should NEVER use. Make sure your code reviewers check code against the list.
You can set the Compatibility Level to SQL Server 2005 (90) under the Options section of the database properties.
Right click the database, select Properties, and then select Options.

Programming without a DB

I have a project to work on. The project requires SQL server. I am using LINQ. So since I dont have SQL server installed on my computer, is it possible I can just use the LINQ designer to create my classes? And then when I do publish my website to a online hosting company, I can use the LINQ to create the tables and stuff?
Is this overly complicated? I want to stay away from using SQLite, or SQL Server Express or SQL server compact because its hard to transfer stuff. Atleast for me. My one problem is also that I want to use ASP.NET Membership stuff. If I run the .exe tool to automatically create my tables, how would I accomplish this without using a db? I tried using SQL server compact (mdf file i think?) but apparently the tool does not support it.
So what are my options here. I'd like to being programming right away however paying for hosting online is just a waste of money for me right now until i have some of the project done.
I'd suggest installing SQL Server Express Edition on your computer and using that as your database during development. I know that there can be some confusion and difficulty when upgrading your development database from SQL Server Express Edition to the professional edition on the hosting company's database servers, but I'm confident that the time you will need to spend on that will be dwarfed by the time you'd need to spend to build and use a mock database layer, not to mention the extra testing you'd need to do once you moved to a real database.
Also, the challenge in moving from SQL Server Express Edition to the professional edition at the hosting company shouldn't be too bad if you choose a web host that has tools for importing your SQL Server Express Edition database into their database server. (Some have it so you can just upload your SQL Server Express .mdf file and it will automatically import it into their database server.)
Two things you can do
Install Sql Server Express on your development machine (or a server on your LAN). This way you will have a local database to develop and test on.
Not necessary, but you "could" try to use Entity Framework in place of LINQ, and use Code First mapping.
Also with Sql Server Express, you can do a lot of your database work right from Visual Studio (providing you're running VS Pro).
I want to stay away from using SQLite, or SQL Server Express or SQL server compact because its hard to transfer stuff. Atleast for me.
Upgrading shouldn't be too difficult.
My one problem is also that I want to use ASP.NET Membership stuff. If I run the .exe tool to automatically create my tables, how would I accomplish this without using a db? I tried using SQL server compact (mdf file i think?) but apparently the tool does not support it.
aspnet_regsql.exe works on Sql Server Express
Use SQL Server Express. It is free. Easy to install in your development environment. In SQL Server Management Studio (SSMS), you can right-click on a table and generate scripts to create the table if you did this from the graphical designer. All you have to do is run the script on the new server. There are free tools that can create/transfer data as well.
What are you going to do down the road when you need to test changes? I hope you don't plan on using the production database.
Just generate your entities by hand, later you would be able to easily attach SQL Server to all this stuff.
Create classes and mark them with required attributes (I don't remember their exact name,check MSDN)
P.S I just can't believe SQL Server Express is not enough for you )

MS SQL database Admin/IDE

I'm using MS SQL for a project, but have always used MySql in the past. MySql has a really nice interface which lets you build queries, offers help, backup etc.
What free programs are there for MS Sql that can do this. I'm currently a student so I have free access to MS Sql but the only interface I have for it right now is Visual Studio 2008.
Any suggestions?
The SQL Server Management Studio is available in an "Express" edition as well. It's a separate download from SQL Server Express, though.
SQL Server Management Studio should come with SQL Server and is quite a nice and easy to use administrator tool.
create DBs, tables etc.
control permissions
run queries
and much much more