Category: SQL Server 2005

Duplicating a database in SQL Server Express

With SQL Server Standard Edition and above, it is easy to copy a database. You simply have to right-click on its name, select Tasks and select Copy Database… However that menu item is not there in SQL Server Express. Googling for a solution, I found a script that does just that, but it was written […]

Continue reading

Permission problem to run msdb.dbo.sp_send_dbmail

I needed to be able to send emails from a stored procedure using something like EXECUTE msdb.dbo.sp_send_dbmail @recipients=’address@domainname.com’, @subject = ‘Test email’, @body = ‘Test email body’ The solution was to add the user I was using to run the above query to the msdb database and to assign the role DatabaseMailUserRole to the user: […]

Continue reading

SQL Server Profiler and ALTER TRACE permission

Yesterday, I wanted to use SQL Server Profiler to check what was happening on the database side of an application I am developping. However, SQL Srever Profiler was giving me the following error message: In order to run a trace against SQL Server you must be a member of sysadmin fixed server role or have […]

Continue reading

Changing collation

Once, I was in a situation where I had to change the collation of a database. This is not an easy task, since collations are defined at three levels: Database, Table and Columns. So even, if you change the database collation, all the table and fields will still retain the original collation. Changing collation in […]

Continue reading

Disabling triggers and constraints

Recently, I was in a situation where I had to move data from an old version of a database to a newer version of the same database. The structure of the database had changed slightly. I was trying to figure out what data to move first. I wanted to move data that was referenced before […]

Continue reading

Multiple Nulls in a column with a UNIQUE constraint

I came accross a situation where I needed to temporarily insert multiple rows in a table with a Null value in a column with a UNIQUE constraint on it. In other words, I wanted the values in that column to be unique, except when they are Null. According to ANSI SQL specifications, this should be […]

Continue reading

Comparing IDENTs in two versions of a database

For the past few days, I have been working on the new version of a database. The database was in development and had to go in production. Of course, the right structure and lookup tables data was in the development version of the database and the good data was in the old production database. Both […]

Continue reading