Archive for the ‘SQL Server 2005’ Category
Database Script Generation
This tool will script your database objects and data into a neat script:
Disable all constraints on SQL
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!
Database Unit Testing
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!
SQL Server rules
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
SQL Server 2005 Database Diagram Problem
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 Server3: EXEC SP_DBCMPTLEVEL '<database_name>, '90';4:5: --alter the user7: ALTER AUTHORIZATION ON DATABASE::<database_name>TO [<valid_user (domain\username)>]