SQL SERVER – 2005 – Version Information and Additional Information – Extended Stored Procedure xp_msver

I was glad when I discovered this Extended Stored Procedure myself. I always used different syntax to retrieve server information. Many of information I was looking up using system information of the windows operating system. Syntax: EXEC xp_msver ResultSet: Index Name Internal_Value Character_Value —— ——————————– ————– ————————————- 1 ProductName NULL…
Read More

SQL SERVER – Rename Database to New Name Using Stored Procedure by Changing to Single User Mode

In my organization we rename the database on development server when are refreshing the development server with live data. We save the old database with new name and restore the database from live with same name. If developer/Jr. DBA have not saved the SQL Script from development server, he/she can…
Read More

SQL SERVER – 2005 – List All The Constraint of Database – Find Primary Key and Foreign Key Constraint in Database

Following script are very useful to know all the constraint in the database. I use this many times to check the foreign key and primary key constraint in database. This is simple but useful script from my personal archive. USE AdventureWorks; GO SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint, SCHEMA_NAME(schema_id) AS SchemaName, OBJECT_NAME(parent_object_id)…
Read More

SQL SERVER – Difference Between EXEC and EXECUTE vs EXEC() – Use EXEC/EXECUTE for SP always

What is the difference between EXEC and EXECUTE? They are the same. Both of them executes stored procedure when called as EXEC sp_help GO EXECUTE sp_help GO I have seen enough times developer getting confused between EXEC and EXEC(). EXEC command executes stored procedure where as EXEC() function takes dynamic…
Read More