I love active participation from my readers. Just a day ago I wrote article about SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database. I just received comment from Jerry Hung who have improved on previously written article of generating text of Stored Procedure.
DECLARE @procName VARCHAR(100)
DECLARE @getprocName CURSOR
SET @getprocName = CURSOR FOR
SELECT [...]
Archive for the ‘Main’ Category
SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database Including Schema
Posted in Author Pinal, Database, SQL, SQL Authority, SQL Documentation, SQL Query, SQL Scripts, SQL Server, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology on November 22, 2008 | No Comments »
SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database
Posted in Author Pinal, SQL, SQL Authority, SQL Cursor, SQL Query, SQL Scripts, SQL Server, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology on November 20, 2008 | 4 Comments »
SQLAuthority Blog reader YordanGeorgiev has submitted very interesting SP, which uses cursor to generate text of all the Stored Procedure of current Database. This task can be done many ways, however, this is also interesting method.
USE AdventureWorks
GO
DECLARE @procName VARCHAR(100)
DECLARE @getprocName CURSOR
SET @getprocName = CURSOR FOR
SELECT s.name
FROM sysobjects s
WHERE type = ‘P’
OPEN @getprocName
FETCH NEXT
FROM @getprocName INTO @procName
WHILE @@FETCH_STATUS = [...]
SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Group Photo
Posted in About Me, Author Pinal, DBA, SQL, SQL Authority, SQL MVP, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority Author Visit, SQLAuthority News, T SQL, Technology, tagged MVP, Openday on November 19, 2008 | 3 Comments »
MVP Open day 2008 is one of the best event happened so far. I have previously written about this event in detail on this blog.
SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Link List
SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - [...]
SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa
Posted in About Me, Author Pinal, SQL, SQL Authority, SQL MVP, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority Author Visit, SQLAuthority News, T SQL, Technology, tagged MVP, Openday on November 14, 2008 | No Comments »
I will be attending South Asia MVP Open Day 2008 on November 15 - 17, 2008 at Hotel Kenilworth Resorts, Goa. I am very excited as this will be my first Open Day event after being MVP. Microsoft Most Valuable Professionals (MVPs) are exceptional technical community leaders from around the world who are awarded for [...]
SQL SERVER - Delete Backup History - Cleanup Backup History
Posted in Author Pinal, Best Practices, Database, SQL, SQL Authority, SQL Backup and Restore, SQL Query, SQL Scripts, SQL Server, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology on November 11, 2008 | 3 Comments »
SQL Server stores history of all the taken backup forever. History of all the backup is stored in msdb database. Many times older history is no more required. Following Stored Procedure can be executed with parameter which takes days of history to keep. In following example 30 is passed to keep history of month.
USE msdb
GO
DECLARE [...]
SQL SERVER - Check Database Integrity for All Databases of Server
Posted in Author Pinal, Best Practices, SQL, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Server DBCC, SQL Tips and Tricks, T SQL, Technology on November 10, 2008 | No Comments »
Today we will see quick script which will check integrity of all the database of SQL Server.
EXEC sp_msforeachdb ‘DBCC CHECKDB(”?”)’
Above script will return you lots of messages in resultset. If there are any errors in resultset they will be displayed in red text. If everything is black text there is no error. Typical output of [...]
SQL SERVER - Refresh Database Using T-SQL
Posted in Author Pinal, SQL, SQL Authority, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Server DBCC, SQL Stored Procedure, SQL Tips and Tricks, T SQL, Technology on November 7, 2008 | 2 Comments »
Yesterday I received following questions on blog. Ashish Agarwal asked following question.
Hi Pinal,
Can we refresh a database (like we do by right clicking database node in object explorer and clicking on refresh) thru SQL Query?
If yes, can you please tell me the query?
Thanks,
Ashish Agarwal
Answer to above question is NO. It is not possible to do [...]
SQLAuthority News - 5 Millions Visitors - 2 Anniversary - Authors Note on Economy Slow Down and Job Opportunity - SQL Server
Posted in About Me, Author Pinal, Best Practices, DBA, Database, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, T SQL, Technology on November 6, 2008 | 4 Comments »
I just received following screen shot from one of the regular reader of SQLAuthority.com blog. He pointed out important milestone for our blog. We have crossed 5 millions visitors. In less than 2 years SQLAuthority.com blog has been visited by 5 millions visitors. I even missed the anniversary our blog. On November 1st 2008 SQLAuthority.com [...]
SQL SERVER - Clear Drop Down List of Recent Connection From SQL Server Management Studio
Posted in Author Pinal, Best Practices, DBA, Database, SQL, SQL Add-On, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology on November 5, 2008 | 1 Comment »
Quite often it happens that SQL Server Management Studio’s Dropdown box is cluttered with many different SQL Server’s name. Sometime it contains the name of the server which does not exist or developer does not have access to it. It is very easy to clean the list and start over.
Delete mru.dat file from following location.
For [...]
SQL SERVER - Fix : Error: 4064 - Cannot open user default database. Login failed. Login failed for user
Posted in Author Pinal, SQL, SQL Authority, SQL Error Messages, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology on November 4, 2008 | 1 Comment »
I have received following question nearly 10 times in last week though emails. Many users have received following error while connecting to the database. This error happens when database is dropped for which is default for some of the database user. When user try to login and their default database is dropped following error shows [...]
SQL SERVER - Fix : Error : Login failed for user ‘UserName’. The user is not associated with a trusted SQL Server connection
Posted in Author Pinal, SQL, SQL Authority, SQL Error Messages, SQL Query, SQL Security, SQL Server, SQL Tips and Tricks, T SQL, Technology on November 2, 2008 | 2 Comments »
Recently I have got two desktop computers at home and both of them are very powerful machine.
Machine 1 : Windows Vista SP1 with SQL Server 2008
Machine 2 : Windows 2003 with SQL Server 2005 with SP2
When I was trying to connect from SQL Server 2008 to SQL Server 2005 using Windows Authentication I was getting [...]
SQL SERVER - Stored Procedure WITH ENCRYPTION and Execution Plan
Posted in Author Pinal, SQL, SQL Authority, SQL Query, SQL Scripts, SQL Security, SQL Server, SQL Tips and Tricks, T SQL, Technology on November 1, 2008 | 3 Comments »
Stored Procedures are very important and most of the business logic of my applications are always coded in Stored Procedures. Sometime it is necessary to hide the business logic from end user due to security reasons or any other reason. Keyword WITH ENCRYPTION is used to encrypt the text of the Stored Procedure. One SP [...]
SQL SERVER - DECLARE Multiple Variables in One Statement
Posted in Author Pinal, Best Practices, SQL, SQL Authority, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology on October 31, 2008 | 2 Comments »
Just a day ago, while I was enjoying mini vacation during festival of Diwali I met one of the .NET developer who is big fan of Oracle. While discussing he suggested that he wished SQL Server should have feature where multiple variable can be declared in one statement. I requested him to not judge wonderful [...]
SQL SERVER - Simulate INNER JOIN using LEFT JOIN statement - Performance Analysis
Posted in Author Pinal, SQL, SQL Authority, SQL Interview Questions and Answers, SQL Joins, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology on October 25, 2008 | 4 Comments »
Just a day ago, while I was working with JOINs I find one interesting observation, which has prompted me to create following example. Before we continue further let me make very clear that INNER JOIN should be used where it can not be used and simulating INNER JOIN using any other JOINs will degrade the [...]
SQLAuthority News - TOP Downloads - Bookmark
Posted in Best Practices, Database, Outsourcing Technology, SQL, SQL Authority, SQL Download, SQL Interview Questions and Answers, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority News, Software Development, T SQL, Technology on October 24, 2008 | 1 Comment »
Recently I have got many many request for SQL Server Interview Questions and Answers as well related articles. It seems many people are looking for Job or appearing for interview at this time of the year. I have included list of the my top downloads in side bar of the blog, still I receive many [...]
SQL SERVER - Transaction and Local Variables - Swap Variables - Update All At Once Concept
Posted in Author Pinal, SQL, SQL Authority, SQL Performance, SQL Query, SQL Scripts, SQL Security, SQL Server, SQL Tips and Tricks, T SQL, Technology on October 20, 2008 | 3 Comments »
This article is inspired from two sources.
1) My year old article - SQL SERVER - Effect of TRANSACTION on Local Variable - After ROLLBACK and After COMMIT
2) Discussion with SQL Server MVP - Jacob Sebastian - SQLAuthority News - Author Visit - SQL Hour at Patni Computer Systems
I usually summarize my article at the end, [...]
SQL SERVER - Introduction to CLR - Simple Example of CLR Stored Procedure
Posted in Author Pinal, SQL, SQL Authority, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Stored Procedure, SQL Tips and Tricks, SQL Utility, Software Development, T SQL, Technology, tagged CLR on October 19, 2008 | 4 Comments »
CLR is abbreviation of Common Language Runtime. In SQL Server 2005 and later version of it database objects can be created which are created in CLR. Stored Procedures, Functions, Triggers can be coded in CLR. CLR is faster than T-SQL in many cases. CLR is mainly used to accomplish task which are not possible by [...]
SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice - Part 2
Posted in Author Pinal, Best Practices, SQL, SQL Authority, SQL DateTime, SQL Function, SQL Performance, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology on October 18, 2008 | 1 Comment »
A year ago I wrote post about SQL SERVER - Retrieve - Select Only Date Part From DateTime - Best Practice where I have discussed two different methods of getting datepart from datetime.
Method 1:
SELECT DATEADD(D, 0, DATEDIFF(D, 0, GETDATE()))
Method 2:
SELECT CONVERT(VARCHAR(10),GETDATE(),111)
I have summarized my post suggesting that either method works fine and I prefer to [...]
SQL SERVER - Get Common Records From Two Tables Without Using Join
Posted in Author Pinal, SQL, SQL Authority, SQL Joins, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, T SQL, Technology on October 17, 2008 | 6 Comments »
I really enjoy answering questions which I receive from either comments or Email. My passion is shared by SQL Server Expert Imran Mohammed. He frequently SQL community members by answering their questions frequently and promptly.
Sachin Asked:
Following is my scenario,
Suppose Table 1 and Table 2 has same column e.g. Column1
Following is the query,
1. Select column1,column2 From [...]
SQL SERVER - Downgrade Database to Previous Version
Posted in Author Pinal, Database, SQL, SQL Authority, SQL Performance, SQL Query, SQL Server, SQL Tips and Tricks, Software Development, T SQL, Technology on October 16, 2008 | 2 Comments »
Today I am writing on the topic which I do not like to write much. I enjoy writing usually positive or affirmative posts. Recently I got email from two different DBA where they upgraded to SQL Server 2005 trial version on their production server and now as their trial version was expire they wanted to [...]
-
About Pinal Dave
Pinalkumar Dave is Microsoft SQL Server MVP and author of over 700 SQL Server articles. He has five years experience as Principal Database Administrator in MS SQL Server 2008/2005, .NET (C#) and ColdFusion MX. He has a Masters of Science degree in Computer Networks, along with MCDBA, MCAD(.NET) and ColdFusion Advanced MX Certifications.
MVP Profile

-
Blog Stats
- 5,224,481 Readers
-
SQLAuthority Links

My Homepage
My Resume
My Other Blog
SQL Server Mag Articles
--------------------
SQLAuthority
Best Articles
Favorite Articles
SQL Script Bank
Top Downloads
--------------------
SQL Interview Q & A
SQL Coding Standards
SQL FAQ Download
--------------------
SQL Random Article
Search SQLAuthority
Subscribe Email Update
SQLAuthority Feed
Translate SQLAuthority
--------------------
Jobs @ SQLAuthority
Find Your IP
Categories
- About Me (35)
- Author Pinal (509)
- Best Practices (39)
- Data Warehousing (25)
- Database (226)
- DBA (198)
- Main (67)
- Outsourcing Technology (4)
- Software Development (73)
- SQL (777)
- SQL Add-On (65)
- SQL Authority (777)
- SQL Backup and Restore (48)
- SQL Coding Standards (84)
- SQL Constraint and Keys (45)
- SQL Cursor (63)
- SQL Data Storage (19)
- SQL DateTime (33)
- SQL DMV (1)
- SQL Documentation (280)
- SQL Download (419)
- SQL Error Messages (360)
- SQL Function (96)
- SQL Humor (21)
- SQL Index (67)
- SQL Interview Questions and Answers (57)
- SQL Joins (357)
- SQL MVP (20)
- SQL Performance (406)
- SQL Puzzle (7)
- SQL Query (777)
- SQL Scripts (512)
- SQL Security (365)
- SQL Server (777)
- SQL Server DBCC (253)
- SQL Stored Procedure (131)
- SQL Tips and Tricks (777)
- SQL Trigger (40)
- SQL User Group (11)
- SQL Utility (55)
- SQL XML (2)
- SQLAuthority (17)
- SQLAuthority Author Visit (32)
- SQLAuthority Book Review (29)
- SQLAuthority News (149)
- SQLAuthority Website Review (18)
- T SQL (777)
- Technology (777)
-
Top Posts
- SQL SERVER - Insert Data From One Table to Another Table - INSERT INTO SELECT - SELECT INTO TABLE
- SQL SERVER - Insert Multiple Records Using One Insert Statement - Use of UNION ALL
- SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
- SQL SERVER - Import CSV File Into SQL Server Using Bulk Insert - Load Comma Delimited File Into SQL Server
- SQL SERVER - Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}
- SQL SERVER - Restore Database Backup using SQL Script (T-SQL)
- SQL Server Interview Questions and Answers Complete List Download
- SQL SERVER - Convert Text to Numbers (Integer) - CAST and CONVERT
- SQL SERVER - 2005 List All Tables of Database
- SQL SERVER - TRIM() Function - UDF TRIM()
- SQL SERVER - Fix : Error: 18452 Login failed for user '(null)'. The user is not associated with a trusted SQL Server connection.
- SQL SERVER - Shrinking Truncate Log File - Log Full
-
Recent Posts
- SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database Including Schema
- SQLAuthority News - SQL Server White Paper: SQL Server 2008 Compliance Guide
- SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Group Photo
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 3
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 2
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 1
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Link List
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa
- SQLAuthority News - RML Utilities - Usage and Additional Help
- SQLAuthority News - Download RML Utilities for SQL Server
- SQL SERVER - Delete Backup History - Cleanup Backup History
- SQL SERVER - Check Database Integrity for All Databases of Server
- SQLAuthority News - SQL Server 2008 Book Online Updated in October 2008
- SQL SERVER 2008 - Connect Visual Studio 2005 Patch Download
-
Recent Comments
- Bob Zagars on SQL SERVER - Better Performance - LEFT JOIN or NOT IN?
- COBRASoft on SQL SERVER - 2005 - Database Table Partitioning Tutorial - How to Horizontal Partition Database Table
- SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database Including Schema Journey to SQL Authority with Pinal Dave on SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database
- Steve Hatchard on SQL SERVER - Difference between DISTINCT and GROUP BY - Distinct vs Group By
- Igor on SQL SERVER - FIX : Error 945 Database cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server error log for details
- Rosales on SQL SERVER - Retrieve Current Date Time in SQL Server CURRENT_TIMESTAMP, GETDATE(), {fn NOW()}
- Kunal Kumar on Contact Me
- Lutz Mueller on SQL SERVER - SELECT 1 vs SELECT * - An Interesting Observation
- Steve Walker on SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
- Rahul on SQL SERVER - 2005 - Display Fragmentation Information of Data and Indexes of Database Table
- Rahul on SQL SERVER - 2005 - Display Fragmentation Information of Data and Indexes of Database Table
- Makarov on Contact Me
- babu on SQL SERVER - Do Not Store Images in Database - Store Location of Images (URL)
- paresh13 on SQL SERVER - 2005 List All Tables of Database
- Manish on SQL SERVER - 2005 - Create Script to Copy Database Schema and All The Objects - Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
Archives
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
-
Pages
-
Latest Articles
-
pinaldave
- SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database Including Schema
- SQLAuthority News - SQL Server White Paper: SQL Server 2008 Compliance Guide
- SQL SERVER - Simple Use of Cursor to Print All Stored Procedures of Database
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Group Photo
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 3
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 2
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Day 1
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa - Link List
- SQLAuthority News - Author Visit - South Asia MVP Open Day 2008 - Goa
- SQLAuthority News - RML Utilities - Usage and Additional Help
-
-
Click Cloud
About Me Author Pinal Best Practices Database Data Warehousing DBA Main Outsourcing Technology Software Development SQL SQL Add-On SQLAuthority SQL Authority SQLAuthority Author Visit SQLAuthority Book Review SQLAuthority News SQLAuthority Website Review SQL Backup and Restore SQL Coding Standards SQL Constraint and Keys SQL Cursor SQL Data Storage SQL DateTime SQL DMV SQL Documentation SQL Download SQL Error Messages SQL Function SQL Humor SQL Index SQL Interview Questions and Answers SQL Joins SQL MVP SQL Performance SQL Puzzle SQL Query SQL Scripts SQL Security SQL Server SQL Server DBCC SQL Stored Procedure SQL Tips and Tricks SQL Trigger SQL User Group SQL Utility SQL XML Technology T SQL


