change collation of DB SQL Server 2008 - collation

I have created some new databases in SQL Server 2008 Express (10.0.1600.22) and I have also restored one from SQL Server 2005 Express (9.00.1399.06).
The collations for these are different and I cannot execute queries across them as a result. So I am trying to change the restored database collation
from: SQL_Latin1_Genral_CP1_CI_AS
to: Latin1_General_CI_AS
However the new collation does not appear in the list of options. Not sure if this is possible.
BTW - workarounds that are not options:
I cannot script the data from sql server 2005 express (it seems - I may be missing something)
I cannot script the DB on 2K8 server as I get an out of memory exception when doing that :-(

If the collation is visible for other databases on your instance but not this specific one restored from a 2005 instance I wonder if the list displayed is dependent upon the databases compatibility model.
Maybe try changing the compatibility mode of the restored database to 100 to see if it appears in the list of options.
Note changing the database collation will not affect existing columns. Here's a script that may help with that.

Related

How to combine Entity Framework and SQL Compact in Visual Studio 2012?

I am using the MS Entity Framework and Visual Studio 2012 in combination with the SQL Server Express. Now I want to use the EF in combination with an SQL Server Compact Edition database.
The design process will be model first.
I created an SQL CE database file in VS and started the design with a database model. I can create the .slqce file, containing the database schema definitions without any problems.
Actually my Problem is, that I can't find out how to execute this file on the database.
To test another approach, I created the database tables, columns... in the Server Explorer and used this to create an entity model. This worked well, but again, I don't know how to update the DB with changes, made inside the model.
What am I missing here?
You can use my SQL Server Compact Toolbox addin to create the database file and execute the script. You may need a modified template, as I describe here http://erikej.blogspot.dk/2013/02/fixing-entity-framework-designer.html

Visual Studio 2012 SQL Database Project with SSDT

I'm starting to use Visual Studio 2012 with integrated SQL Server Data Tools and although I watched 2 of microsoft's video's on getting started with SQL Database Projects I'm still having trouble understanding how to work with them especially since I'm new to db development.
Some questions:
What is the difference between Importing a database or adding a reference to the database?
What is the difference between Server Explorer and SQL Server Object Explorer tabs? In one I can browse the database through localhost\SQLEXPRESS.dbname and the other goes through localdb\Projects. At what point are these synchronized?
How do I change the Target Database Name under the Project's properties?
1) Importing a data base creates a project that includes all of the databases artifacts. Adding a database as a reference allows a project to access the database. So if you have a SSDT project and a c# project that uses the db, the c# project gets the reference. You could choose to create the SSDT project by importing an existing db.
2) SQL Server Object Explorer is part of SSDT and allows you do perform online SQL development including creating new artifacts, adding data to tables, and executing scripts.
3) To change the target database name for debugging purposed (where the database goes when you build/debug) change the target connection string in the debug tab of the properties menu of the project.
I've found this link to be quite helpful.
There are many differences between SQL Server Object Explorer (SSOX) and Server Explorer. Here's a couple:
SSOX allows you to launch refactoring operations
SSOX provides a logical view of your source code in Solution Explorer
In short, SSOX targets database development whereas Server Explorer is (I think) a generic hierarchical viewer for many server types.
Regards
Jamiet

t-sql database restore without security

Is there a way to ignore the security portion (users) of a database when doing a restore? I know there is a way to script them all out, but we are restoring production databases on multiple dev machines, each having their particular set of users that we need to keep. Currently they are overwritten by production users.
[Microsoft SQL Server 2008 (SP1) Developer Edition (64-bit)]
There's no way to eliminate the security portion from a backup. It is possible to do a schema comparison using Visual Studio 2010 or higher before doing the restore and generate a script from that to do the permission changes.
See Compare and Synchronize Database Schemas.

InstallShield 2012: Need to switch between sql scripts (sql server & oracle) based on property

The web applications I am installing can run against either a SQL Server or Oracle database. I need to be able to determine which database the user has (client is suggesting a property file) and then dynamically tell InstallShield whichSQL script to run, I know I can figure out how to determine which database is installed. My question is how do I configure the Feature/Component and tell InstallShield which script to use.
I don't have any Oracle servers available to me nor do I have the Oracle Instant Client. If I did, it seems I'd use a Basic MSI project included in InstallShield to build an Oracle Instant Client MSI and add it to my installer as a setup prerequisite. Kind of odd but I guess they couldn't get IBM / Oracle to play nicely.
So let's say I had all of that. I'd create a Sql connection that supported both MS and ORA SQL and build it. I'd run the installer with logging on and use the SQLLogin dialog to browse to a SQL instance and an Oracle Instance.
Then I'd look at that logfile and see if there's any evidence of the built-in InstallShield SQL custom actions setting a property that indicates the type and/or version of database server that it connected to. Hopefully something will surface because I didn't find anything in the documentation.
Once I figured that out, I'd use the property in a conditional expression so that the SQL scripts only ran on the type of database server they were intended.

Cannot open new .mdf file to C# project

I cannot attach a new Service based database(.mdf) to a C# project that I started. It shows:
Connections to SQL Server Database file(.mdf) require sql server 2008 express to be installed and running on a local computer.The current version of the SQL express can be downloaded.
But I already have SQl Server 2008 R2 installed.I've learned that a .mdf file cannot be "just" attached if the SQl server is a full version, then do I have to create a new database to accomplish the task?Or is there anything else that I can do?
As it's mentioned by Mostafa you should go to Tools->Options->Database Tools->Data Connections->SQL Server Instance Name and blank the SQLEXPRESS in that field. actually there is no need for instance name just blank it.
Use the VS 2010 menu Tools/Connect to database and, in the dialog that opens, fill the field "Attach a database file". AFAIK it's a known problem of VS 2010.
The visual studio has a default sql server instance name to connect to. The installer sets it up to point to the SQL Server Express by default. You have to change the Tools->Options->Database Tools->Data Connections->SQL Server Instance Name to point to your installed SQL Server instance name.

Resources