LinqToSql - Necessary to generate .dbml for each SQL Server version? - linq-to-sql

I'm developing an application that needs to operate against SQL server 2003, 2005, and 2008. I'd like to transition from using T-SQL stored procedures to using Linq, as we currently don't have a database programmer, and thus making any fixes or adding any features is a slow, difficult process. In contrast, working with LinqToSql in other projects has been a breeze.
Will a .dbml file generated against SQLServer 2008 work if used against previous versions of SQL Server, assuming the table structures are the same?
As we already have to support three slightly different database schemas, having to generate a DataContext for each SQL version, along with our additional data layer functionality, would be a showstopper.

SQL Server 2005, 2008: No problems.
SQL Server 2000, 2003: Issues with server side paging (.Skip(), .Take()), but other than that, no.
I am developing on a SQL Server 2005 and hosting the live system on a SQL Server 2008 without any hiccups.
You will experience problems with anything earlier than SQL Server 2005 and LINQ to SQL's implementation of .Skip() if you were ever to use it, as LINQ to SQL translates it to ROW_NUMBER in T-SQL - and this is only a part of SQL Server 2005 and onward.
See this related question: Which versions of SQL Server does LINQ to SQL support?

Related

How to check sql script compatibility agains SQL 2008

I have installed SQL 2012 and I must create a application compatibility with SQL 2008. Is any way to check that all scripts that I write are compatibility with SQL 2008 without installing SQL 2008?
I believe that there are two thing that you will need to do to ensure that your app is compatible with SQL Server 2008.
First, the easiest way that I have found to find issues caused by deprecation between versions is to use the sql server profiler tool.
http://www.mssqltips.com/sqlservertip/1370/identifying-deprecated-sql-server-code-with-profiler/ is an excellent introduction into that.
Second, you need to change the compatibility level of the database to the level of SQL Server 2008.
ALTER DATABASE database_name
SET COMPATIBILITY_LEVEL = { 90 | 100 | 110 }
So for you that would be ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 100;
Some things to keep in mind. This will not change the underlying way that sql server executes the query internally, new enhancements to the query optimizer or algebrizer will not be excluded because of the compatibility level. From what I understand this functionality mainly disables language constructs that were not introduced in the version that you are interested in. That being said, it shouldn't make any difference in what you are trying to accomplish.
This is a similar question (with a good answer) regarding 2008 and 2005: Using SQL Server Express 2008 with SQL Server 2005 database -how to check for compatibility
You can find here the complete list of compatibility mode changes: ALTER DATABASE Compatibility Level (Transact-SQL)

Data in table is not resolved correctly after Oracle 11g to MSSQL2012 migration

We have recently migrated a database from Oracle 11g to SQL Server 2012 SP1. We also performed migrated that same database from Oracle 11g to SQL Server 2008 R2.
The database migration from Oracle to SQL Server 2008 has been performed successfully; our application can exploit that database without any issues. We have however encountered a problem with the migration from Oracle to SQL Server 2012 SP1.
When retrieving data from a specific column (type: VARCHAR(MAX)), in some cases, instead of having the content of the stored string displayed, we only have a "/" displayed. When we look at the data stored in the column, everything is there. Our application uses and OBDC configured with the MSSQL11 driver.
What we also observed:
The varchar(max) column is retrieved successfully when using the MSSQL10 driver;
Is there anything that we might have to change to make this work? Don't hesitate to ask for more information.
Thank you!

Restoring SQL 2008 R2 db on SQL 2008 Standard

I'm trying to take a SQL Server 2008 R2 Expression db and restore it on my local SQL Server 2008 standard, however it gives me the error:
The media family on device 'C:\jtoth\Backups\ucampus.bak' is incorrectly formed. SQL Server cannot process this media family.
R2 is version 660 and standard is 655 and I know that you can't restore to an older version, but there has to be some way around this. Is there some free tool for scripting out the entire R2 database (including not just structure but inserts for the data) that I can then run on my standard instance?
Normally one of
SSIS (via the import/export wizard)
3rd party tool from Red Gate or similar.
You're right that the backup cannot be restored. See: SQL Server 2008 R2 bumps the database version. Your best bet would probably be the Red-Gate compare tools.
Use the Copy Database Wizard!, the Copy Database Wizard lets you move or copy databases and their objects easily from one server to another.
In SQL Server Management Studio, right click on the database, choose Tasks, then "Generate Scripts". Options in there to generate full scripts including the table structure and all the data. Additionally you can choose which version to script for.
Visual Studio has a Database Compare tool. Might be handy. See the Data menu. Not as good as 3rd party tools though..
Just an idea - how about changing compatibility level to SQL Server 2005 before backup? That is of course if nothing 2008 specific was used.

Using Visual Studio 2008 DBPro to convert database from Sql 2005 to Sql Server 2008

I have a DBPro database project that was created for Sql 2005. I am trying to build this on a different environment, with Sql 2008, and I am getting the following error:
MSBUILD : Build error TSD158: An unsupported target database version was encountered.
I couldn't find much on this error, and I am unclear what is the conflict. I have tried to change the buildversion element in the database project from 9.0.21022.8 to 10.0.0.0 but that didn't make any difference. I am out of ideas. Any thoughts?
To target SQL Server 2008, don't you need some GDR update? See http://blogs.msdn.com/gertd/archive/2008/11/25/visual-studio-team-system-2008-database-edition-gdr-rtm.aspx
Also, it might be easier to take your database, restore it on SQL Server 2008 (and let the database upgrade the database itself). Then just start a new project where you suck down the schema. But I still think you'll need the GDR in order to do that.

How to move SQL Server 2008 to the cloud?

I have a large (~40gb) SQL Server 2008 database that I would like to move to the cloud.
The database uses a lot of SQL Server 2008 specific (and non-specific) features (SQLCLR, xml, indexes, partitions, etc). Thus, my preference would be to use the exact database, but in the cloud.
What are my options? The new SQL Azure only allows small databases, and a subset of TSQL. I want to whole thing. I would still like to connect to it using Management Studio.
If you want "the whole thing" and want to be able to connect to your SQL-Azure store with SSMS, you'll have to wait until SQL Server 2008 R2 (a.k.a. SQL Server 2010) is out - sometime in 2010.
The SQL Server 2008 R2 November CTP has just had such an announcement - the SSMS for that version will be supporting SQL Azure.