In this issue

Featured Contents


Featured Script

SQL Toolbelt Want to work faster with SQL Server?
If you want to work faster try out the SQL Toolbelt. "The SQL Toolbelt provides tools that database developers as well as DBAs should not live without." William Van Orden. Download the SQL Toolbelt here.
SQL DBA Bundle Top 5 hard-earned Lessons of a DBA
New! Part 4, ‘Disturbing Development’ by Grant Fritchey, features the return of Joe Deebeeay and a server-threatening encounter with ORMs - read it here.
SQL Prompt Make working with SQL a breeze
SQL Prompt 5 is the effortless way to write, edit, and explore SQL. It's packed with features such as code completion, script summaries, and SQL reformatting, that make working with SQL a breeze. Try it now.

In This Issue

Loginless In Seattle

Identify orphaned Database Users and differentiate them from "Loginless" Database Users. More »

The Ten Commandments of SQL Server Monitoring

It is easy to get database monitoring wrong. There are several common-sense rules that can make all the difference between a monitoring system that works for you and helps to avoid database problems, and one that just creates a distraction. Adam Machanic spells out the rules, based on his considerable experience with database monitoring. More »

Disturbing Development

Part 4 of the top 5 hard earned lessons of a DBA. More »

From the SQLServerCentral Blogs - How to Tell Your Windows Azure SQL Database Moved

The very concept of the Windows Azure SQL Database (WASD) is predicated on the up-time created by having three active copies... More »

From the SQLServerCentral Blogs - Attach Database with Missing NDF File

I wonder if you’ve had the situation that I had before where you have to attach a database with one... More »

Editorial - Better Coding, More Savings

I'm sure most of us would like to think that we write fairly efficient code. However the reality for many of us might be that we don't actually know. Many of us use the same patterns and practices that we've been using for a long time, rarely changing. When we learn a new technique or find a different way of coding that works better, we tend to then use that method over, and over, and over, and over again.

I would guess that if many of us profiled our code, and examined the CPU and network bandwidth we consume, we might be surprised at what we find. CPU and network usage isn't something we are often concerned about. We assume that we've bought a machine and we should be able to use as much of it as we can at any point in time. That's not the best approach, but since we often have more hardware than we need for many processes, it works. It also explains why so many applications struggle as the load increases. They're not coded efficiently.

If you're going to work in the cloud, you better learn to code more efficiently, mostly because it costs money. If you think about your design, you can reduce the amount of resources you use. In the cloud this translates to less cost. In the on-premises world, this means better performance and higher scale. It also means less complaints and phone calls.

Scaling up an application can be hard, but much of the struggle comes from poorly coding your application in the beginning. Most of us have heard the saying that it takes less time to do it right the first time. That's true in many situations, and it's true for your application development. Learn to write more efficient code and use patterns that conserve resources. You'll find your applications will run better, no matter what type of environment hosts them. If you're not sure what patterns and practices work well, read an article or ask a question and find out what efficient techniques others use.

» 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:

I have a table, Customers, with the CustomerID as an identity. I run this query:

 customerID, count(city)
 into CustomerCities
 from Customer
 group by CustomerID

Does the CustomerCities table have a column with the identity property?

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

This question is worth 1 point in this category: T-SQL. 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

What will be the data type assigned for the columns in the temp table when to run this below query? Please select answer.

select * into #temp from 
 select NULL col1, NULL col2 
 union all 
 select null, 'Que'
) A

Answer: Int, Varchar(3)

Explanation: This query will create the int data type in Col1 as the default in the implicit conversion if all the values are specified as NULL in a particular column. Otherwise it will create the data type of the values in the column. In this case Varchar(3) as the result of implicit conversion.

Ref: None found. One appreciated.

» Discuss this question and answer on the forums

Featured Script

Format Currency Into a String

I had a requirement to produce a formatted currency string from within SQL server. I was able to build this scalar-valued function to meet the requirement. 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

How to find the time required to complete for a query which is currently running... - Experts, I have a query which is currently running.. Is there a way to find how much more time it will...

SQL Server 2005 : T-SQL (SS2K5)

BEFORE TRIGGER issue - I know that we don't have access to a MySQL BEFORE trigger but I have a strange issue that I...

how to check if a user is an admin or is a guest? - hi i want to specify if my user is a member of administrator or it is a guest. how can i...

SQL Server 7,2000 : Administration

I would REALLY like some fast help with this problem! - [font="Times New Roman"][size="4"][b][center]I would really like some help with this annoying longlasting problem[/center][/b] [b]So i have built my own computer, and...

SQL Server 2008 : SQL Server 2008 - General

Hash warnings - Hi - Can anbody advise me on the following: I am using red gates sql monitor and every night during the nightly...

Weird grouping problem thats driving my mad! - Can somone help me with the following grouping problem? I have a process which produced a table like the below: [code="sql"]create table...

Update Values on one table based on another table - TRIGGER ??? - Hi, I'm already sorry (especially if Sean is answering again) ... I am quite new to this whole posting stuff, but I...

Sending Multiple Independent Messages to Multiple Users - I have confusion regarding how to [b]send multiple messages to multiple users at the same time[u][/u][/b] at periodic intervals(weekly basis...

Find the second comma - Dear, I have a String='A,B,C'. I want to find A, B, C individually using substing function. There may be 3 select statements....

Date Format Problem with SQL SERVER ENGLISH VERSION - Please, I have installed SQL SERVER 2008 R2 Standard Edition English Language. The Collation of the server is : French_CI_AS. I...

SQL Condition for SSRS multi select parameters - Hi All, I can't figure out the best way to implement here is my simplified table: [code="sql"] declare @tbl table(Id int identity...

I know which *file* is being hammered -- how do I find out *who* is doing the hammering? - I have a production SharePoint system with about 100 databases, it just got really slow, users are complaining a lot. When...

What is a semicolon used for in SQL Server? - Hello All, I have a co worker that uses the semicolon at the end of his SQL statements like Select * From Table1(nolock)...

How to install an oracle linked server on SQL Server 2008 r2 failover cluster manager - How to install an oracle linked server on SQL Server 2008 r2 failover cluster manager I'm reading some articles and applying...

SQL Server 2008 : T-SQL (SS2K8)

Extracting files from "binary" stored in TEXT datatype - I've been asked to look into extracting files (mostly jpg or pdf) from a database where the files are stored...

Writing to local variable from CTE - Can I write to a local variable from inside a CTE? I am trying to get a comma delimited string of...

Whats wrong with it, Transaction mismatch.. Please help. - IF OBJECT_ID('test_parent_table') IS NOT NULL DROP TABLE test_parent_table CREATE TABLE test_parent_table ( id INT, name VARCHAR(30) ) GO IF OBJECT_ID('DataError') IS NOT NULL DROP TABLE DataError CREATE TABLE DataError ( ErrorNo INT, ErrorDesc VARCHAR(1000), ErrorProc VARCHAR(100), ErrorLineNumber INT, ErrorDateTime DATETIME2(7) ) GO IF OBJECT_ID('ThrowError') IS NOT...

SQL Server 2008 : SQL Server Newbies

Trying to copy database from my laptop to my desktop pc - Hi, as you can tell i am a nube here. I am trying to copy SQL database established locally on...

Creating a hierarchy group from one table column containing both parent and child hierarchy info - Hi I need help creating a hierarchy group 'using' the data in [b]Event_Role[/b] column in my sample table to create a...

SQL Server 2008 : SQL Server 2008 High Availability

Where to locate the Witness server when using Mirroring for DR - Hi, I am looking into setting up mirroring for DR purposes. What I want to know is the correct location for...

Mirroring failover : SQL Server 2008 R2 - We use database mirroring ( high safety) for our HA needs. Our application uses db_datareader & db_datawriter role for running the applications. I had...

SQL Server 2008 : SQL Server 2008 Administration

Moving from Standalone to clustered SQL - Hi - We have a standalone SQL box that we need to migrate all the DBs to a new clusted environment...

Career : Events

ABET Program Evaluators Needed - Hi All, I have been asked to help recruit new IT/IS/CS Program Evaluator (PEV) for ABET ([][/url]); the basic duty...

Career : Resumes and Job Hunters

How can I attract Senior Database Administrator candidates? - I have a few full-time DBA positions open on my team, one of which is for a Sr. DBA. We...

Reporting Services : Reporting Services

SSRS ODBC Connectivity - Hi I have create a ODBC connection for Sybase Db and Develop my RDL file. Its working fine when I am...

SSRS Table reporting - Hi there, Anyone can tell me how to fix this table? I have a full range of data - breakdown by product, then...

Permission by department manager from single report to view. - Hello, We are using SSRS 2005 and I have a report I want to give access to 5 different managers the...

Matrix Total - Hello, I'd appreciate if you guys help me with my problem in a matrix. In the following SSRS 2008 matrix, notice...

Data Warehousing : Integration Services

SSIS Package to remove leading 0's - Hey Everyone, :-) I am creating an SSIS package and having some issues removing leading 0's from a field. I cannot...