In this issue

Featured Contents


Featured Script

SQL Search How do you search your database schema?
"I use SQL Search regularly and think it's great." Gregor Suttie, Senior Software Engineer, Pulsion Technology. Download Red Gate SQL Search while it's free.
SQL DBA Bundle Top 5 Hard-earned Lessons of a DBA
Lesson two has now been released! Read ‘Beating Backup Corruption’ and learn from the very best. Read now.
SQL Compare Compare and sync databases with SQL Compare
“SQL Compare is fast, extremely easy to use, full-featured and affordable. I wouldn't bother messing around with anything else.” Adam Machanic, SQL Server MVP. Download a 14-day free trial.

In This Issue

Stored Procedures and SQL Injection

Why do stored procedures help with security? In this piece, MVP Brian Kelley explains why SQL Injection and information gathering are hampered with stored procedures. More »

SQL Saturday #177 - Silicon Valley

The Bay area gets another SQL Saturday this weekend, on Feb 23, 2013. Come have a free day of SQL Server training. More »

Troubleshooting and Fixing SQL Server Page Level Corruption

Corrupt SQL Server databases are the worst nightmare of any SQL Server professional. In any environment, from small business to enterprise, the compromise of integrity and availability of the data can constitute a business emergency. This is especially the case in those organizations reliant on an OLTP data model, for a high-volume website. SQL Server database corruption and disruption of the transaction processing system can cause business repercussions such as large financial losses, a drop in reputation or customer retention, or contractual SLA problems with the service provider, if not managed in-house. More »

From the SQLServerCentral Blogs - SQL Server Naming Standards

Want to start a fight between a bunch of DBAs or database developers? Ask them where the comma should be... More »

Editorial - Practicing Deployments

This editorial is being re-run after a glitch in our newsletter system. Apologies if you have already seen it.

It's said that amateurs practice until they can get something right. Professionals practice until they don't get something wrong. That's the idea, and while professionals make mistakes, they make far fewer than those that don't approach their craft as a professional task.

Many of us in the data industry develop software in some way. Whether we write queries in T-SQL or build projects in .NET, we produce code to accomplish some task. I'd like to think that many of us improve our skills over time, preferably by practicing new techniques and learning from our mistakes. I know some people stick with the tried and true methods without gaining skill over time, which not only hurts one's career, but also doesn't give an employer a reason to value their work.

However the deployment of software, which encompasses more than the developer(s), doesn't improve in many cases. Deployment includes operational people's skills, scheduling dowtime with clients, possible even the briefing of support personel. However the whole process is often performed poorly. Deployments fail, or require more time than expected. People view them as a pain, and software deployment tends to happen less often than it could, resulting in a large software inventory.

There's a great quote from James Moore on how we can deploy software better: "...deployments are hard, but rather than long-winded planning, they need constant practice, testing and refining, and we could only do this by deploying early." Red Gate Software has learned that deploying more often results in the company gaining skill in deploying software, resulting in more successful software changes in applications.

The improvement you make in your software can bring tremendous value to your clients, but only if they can use those features in the software. Learning to push those changes out in a repeatable, professional manner is a great way to ensure your clients and customers trust you to deliver new features and enhancements that meet their needs.

» Join the debate, and respond to today's editorial on the forums

The Voice of the DBA Podcasts

We publish three versions of the podcast each day for you to enjoy.

Everyday Jones

The podcast feeds are available at Comments are definitely appreciated and wanted, and you can get feeds from there. Overall RSS Feed: or now on iTunes!

Today's podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music. Support this great duo at

You can also follow Steve Jones on Twitter:

» To submit an article, rant or editorial, log in to the Contribution Center

Question of the Day

Today's Question:

Given the following code:

USE tempdb;





Will the alter user statement succeed?

Think you know the answer? Click here, and find out if you are right.

This question is worth 1 point in this category: User. We keep track of your score to give you bragging rights against your peers.

We'd love to give you credit for your own question and answer. To submit a QOD, simply log in to Contribution Center.

SQL Server 2012 T-SQL Recipes: A Problem-Solution Approach

SQL Server 2012 T-SQL Recipes is an example-based guide to the Transact-SQL language that is at the core of SQL Server 2012. It provides ready-to-implement solutions to common programming and database administration tasks. Learn to create databases, insert and update data, generate reports, secure your data, and more. Tasks and their solutions are broken down into a problem/solution format that is quick and easy to read so that you can get the job done fast when the pressure is on. Get your copy from Amazon today.

Yesterday's Question of the Day

If I am executing the below code, what is the name of the database returned from the three queries (in the same order of execution).

USE master;

-- Query#1
SELECT DB_NAME() DatabaseName1;

EXECUTE ('USE AdventureWorks2008');

-- Query#2
SELECT DB_NAME() DatabaseName2;

EXECUTE ('USE AdventureWorks2008; USE master');

-- Query#3
SELECT DB_NAME() DatabaseName3;

Answer: Master, Master, Master

Explanation: Database context will not be changed while executing EXECUTE statements. The reason is changes in database context last only until the end of the EXECUTE statement.


» Discuss this question and answer on the forums

SQL Wait Stats Joes 2 Pros

You learn a lot when thrown into a crisis situation, where everyone is looking to you for answers. The system is down, the CEO is pleading to you for answers as the each minute cuts the company’s bottom line. When you are in a hurry, you need some new ideas right away. This book is your helpful tool. When used correctly, you can determine solutions and even related solutions to simple (yet lesser known) areas of SQL Server. Learn what causes SQL tasks to wait or site in queues. Even if your system is not in trouble right now, you can use what you will learn in this book to view the history of wait statistics.

Pick up your copy of this great book from Amazon today.

Featured Script

Get Database Size

Know you database size More »

Database Pros Who Need Your Help!

Here's a few of the new posts today on the forums. To see more, visit the forums.

SQL Server 2005 : Administering

Any thoughts on this process? - This is more of generic programming question. We have a stored procedure which is used on many of our applications...

SQL Server 2005 : Backups

Table Level Rescovery/Restoration - HI All, Can we restore/recover individual Table in Microsoft SQL Server. As far as i know it is not possible Out...

GUID as path and backup file sent to nowhere but no error... ???? - This one is quite strange : I recently created a maintenance plan that take full backups of our BDs and backup...

SQL Server 2005 : Development

Android Development - Hi, i am newbie to Andorid development .. suggest me good material to this journey thanks

SQL Server 2005 : SQL Server 2005 General Discussion

Issue with OSQL - Hi Friends, Requirement : i have a table which contains around 40 columns of which name is a column which i use...

SQL Server 2005 : T-SQL (SS2K5)

Weird Question About Querying with Dates - Okay so this is a very odd situation, one that I have not seen before. I'm trying to query a...

In a Jam - Need Some Help - Hello, I'm urgently working away at this but not able to solve my problem. I'm at the point of needing...

calculating ratios - Hello, I am trying to calculate a ratio, i am pretty sure the problem is in the line * SUM([SUMTOTALVOLUME])) FROM...

Database Design question regarding Normalized Tables - Hey all, Got a theoretical question for you guys. Let's say I have a table that contains information about a store....

SQL Server 2008 : SQL Server 2008 - General

Change in Price Query - I have the data below and I want to update the pricechange column for when the price changes for an...

sp_rename - Hi All, I need to use sp_rename - [url][/url] I need to use it for tables in the following way: For an existing "table_name"...

Multiple SQL servers Consolidation to one Single SQL 2012 Cluster - Hi, Experts. I have a project which includes different 180 databases on around 18 different SQL servers with different versions (2000,2005,2008,2008...

Can Restore Old SQL Versions to SQL 2012 - Hi, Experts. i want to restore old versions of sql backup to sql 2012 using sql server management studio. can we Restore...

Ran out of log space!!! - An archiving process that moves data from my prod db to archive an db consumed my entire log drive. Both...

Newb with SQL in school learning - class project help - Okay here is my situation, I have a database that I had on my website and I want to use...

Giving windows account Read permission to an database - I have an user for whom read access has to be given to number of dbs. I gave db_datareader to that...

What is the best way to access a sql server in another country using the public ip address? - I can access my sql server when both of my computers are connected to a same router. However, when one...

Sql server database tools ?????/ - can you suggest any stree test tools , concurrency checking tools and insert tools for sql server

Waring alters when the database (files MDF, NDF & LDF) reaching the MAX size. - HI Frnds, I need help on setting up alters when the database (files MDF, NDF & LDF) reaching the MAX size....

Export Tables to Excel - Error - Hi to everybody I used to use an application, which creates an SQL Query that exports all Tables of a Database...

DataType confusion - Greetz! I was speaking with a client a few days ago and they said something that contrasted with what I had...

Use an AD group for SQL Authentication - Hi Guys, Our Syspro system uses SQL authentication to connect the users to the database. We're migrating that server and I...

SQL Server 2008 : T-SQL (SS2K8)

Get number of unique values in group of columns - Hi - I have the following scenario and not sure of the best way to write the T-SQL query without a...

Calculation with aliases - Hi, I have the following query: [code="sql'] USE ICP; GO DECLARE @beginDatum Datetime DECLARE @eindDatum Datetime SELECT T.Ticket_ID, UA.Useraccount_First_Name, UA.Useraccount_Last_Name, A.Description, T.Ticket_Accepted_DateTime, T.Ticket_Closed_DateTime, DATEDIFF(second, T.Ticket_Accepted_DateTime, T.Ticket_Closed_DateTime) AS...

Multiple select in same query - I have a sql storeprocedure where i want to count calls to a helpdesk.. The rows in my query for example...

combining the results of multiple select statements in to a single row - All, I have a requirement to combine the results of multiple select statements in to a single row. EX : query 1 : select...

Age - I have a table called member which contains memberid and DOB. How can I calculate age to date based on...

SQL Server 2008 : SQL Server Newbies

Query Help - Okay here is my situation, I have a database that I had on my website and I want to use...

SQL Server 2008 : Security (SS2K8)

Grant Users Permissions at Server Level - Hello, I am looking for a way to restrict access to a SQL Server where only a small group would have...

SQL Server 2008 : SQL Server 2008 High Availability

Log shipping between SQL Server 2000 and SQL 2008R2 - I am going to implement log shipping between 2000 (primary ) and 2008 R2 (secondary). I found there are regular backups are...

SQL Server 2008 : SQL Server 2008 Administration

When DB restored to different server will database mapping and permissions stay? - On Server A I have a database the is overwritten daily by a database on another server [Server B] After the...

SQL Service account rights - Hi, I'm having a little trouble fully understanding why a couple of sql agent jobs are not working correctly. I know...

SQL Tuninig recommendation page - Dear Experts How to read the recommendation page in sql tuning, I mean what should I do ex : the attached picture Thanks lot

What kind of license needed for implement mirroring on a virtual mechine? - Hi Friends, I have to implement mirroring or other DR on VM ware. here my question is What kind of licenses...

Agent Jobs Query - Hi, I would like to check each morning if my agent jobs have completed successfully. What would be the best method...

PF Usage of RAM reaches near to the maximum memory of the Server frequently - Hi All, i have a server which has 8 GB of RAM , 3 GHz, which has SQL Server 2008 Standard Edition...

Data Warehousing : Integration Services

How to automate validation process - Hi, We have the following scenario: We receive CSV files every month for which SSIS packages were built to process the...

Data Warehousing : Analysis Services

Calculations tab SCOPE - Hi, I'm wondering if anyone can help with some scope syntax in the calculations tab. I'm trying test the following: /*...