code & chips

general programming stuff…

Archive for the ‘SQL Server 2005’ Category

Database Script Generation

with one comment

This tool will script your database objects and data into a neat script:

Database Publishing Wizard

Written by Kam

May 21, 2009 at 2:06 pm

Posted in SQL Server 2005

Disable all constraints on SQL

with one comment

Simple SQL Server commands:

Disable all constraints:

EXEC sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' 

Enable all constraints:

EXEC sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL' 

The sp_MSforeachtable is exactly what you think it is.  A system stored procedure by Microsoft that loops through all the tables in the current database. 

The ‘?’ is a parameter to be replaced with the table name and the whole statement is executed.

How very cute!

:)

Written by Kam

May 21, 2009 at 1:41 pm

Posted in SQL Server 2005

Database Unit Testing

leave a comment »

This is one of those “lazy” posts where I am just posting information for me to research later on, but you can have a look now!

AnyDBTest

Written by Kam

May 19, 2009 at 10:32 am

SQL Server rules

leave a comment »

One of my pleasures in software development was SQL. I adored database development. However, in recent times database development is fast becoming a skill in itself much like front end development.

This makes it difficult for someone like me to keep up to speed with the current trends in middle tier development and back end development.

Thank god for these type of sites: SSW’s SQL Server best practices

Written by Kam

July 11, 2008 at 1:11 pm

Posted in SQL Server 2005

SQL Server 2005 Database Diagram Problem

leave a comment »

When trying to create a database diagram I get presented with the following message:

"Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects."

Here’s the solution:

   1: --change the version of SQL Server 
   3: EXEC SP_DBCMPTLEVEL '<database_name>, '90'; 
   4:  
   5: --alter the user 
   7: ALTER AUTHORIZATION ON DATABASE::<database_name>TO [<valid_user (domain\username)>]

Written by Kam

May 29, 2008 at 2:10 pm

Posted in SQL Server 2005

Follow

Get every new post delivered to your Inbox.