SQL Server with Mr. Denny:

T/SQL


August 31, 2009  6:26 PM

Difference between an Index and a Primary Key



Posted by: Denny Cherry
T/SQL

There seams to be some confusion between what a Primary Key is, and what an Index is and how they are used. The Primary Key is a logical object. By that I mean that is simply defines a set of properties on one column or a set of columns to require that the columns which make up the primary key...

August 26, 2009  12:50 PM

Damn rollback scripts are a pain



Posted by: Denny Cherry
sys.tables, T/SQL

Writing release scripts for a database is easy.  What ever new objects you want you create you create, and what ever objects you need to change you change.  Piece of cake.  Rollback scripts however are a bit trickier since you need to know what everything should look like after the script is...


July 20, 2009  11:00 AM

Changing the default owner when creating objects



Posted by: Denny Cherry
Permissions, SQL Server 2005, SQL Server 2008, T/SQL, Tables

When a user that doesn't have sysadmin rights creates objects by default they will be created in the schema that is the users default schema.  Now the catch to this is that if you grant the user rights into the database via a domain group that domain group then the user doesn't have a default...


July 16, 2009  11:00 AM

Non-sysadmins create tables under own schema



Posted by: Denny Cherry
Enterprise Manager, SQL Server 2000, T/SQL, Tables

When using SQL Server 2000 and the user doesn't have sysadmin rights, and their login isn't mapped to the dbo user within the database all objects created will be, by default created under the user schema. This is the normal behavior of SQL Server 2000.  In order to allow users who are not...


May 4, 2009  11:00 AM

How can I remove duplicate records in my tables?



Posted by: Denny Cherry
CTE, DELETE statement, SQL Server 2005, SQL Server 2008, T/SQL

All to often we end up with duplicate rows in a table.  The best way to keep duplicate rows out of the database is to not let them in.  But assume that they are there.  This bit of sample code shows how to delete those duplicate rows quickly and easily in a single statement.  No temp tables...


March 29, 2009  12:05 AM

Viewing the domain groups that are used to get into SQL



Posted by: Denny Cherry
Extended Stored Procedure, Linchi Shea, T/SQL, xp_logininfo

Last week Linchi Shea wrote a posted a blog entry entitled "How does that AD user...

Bookmark and Share     0 Comments     RSS Feed     Email a friend


December 15, 2008  9:00 AM

Back To Basics: Getting Data from an XML Document



Posted by: Denny Cherry
Back To Basics, T/SQL, XML

One of the most popular ways to get data multiple pieces of data in a single parameter from one stored procedure to another, or from a client application to the database is to use XML. This can be done in SQL Server 2000 by using the NTEXT (or TEXT) datatype, and in SQL 2005 using the XML...


December 8, 2008  1:06 PM

Just how awesome are table parameters in SQL Server 2008?



Posted by: Denny Cherry
CREATE PROCEDURE, SQL Server 2008, T/SQL, Table Variables

I would have to say, that one of the coolest new features of SQL Server 2008 is the ability to pass a table as a single parameter to a stored procedure. While we have been able to do this in the past, by using XML to pass more than one value in, then break it apart. But this is just such a...


November 27, 2008  12:15 PM

Back To Basics: Creating Indexes



Posted by: Denny Cherry
Back To Basics, CREATE INDEX, SELECT statement

After you have created your tables, and stored procedures you will have a basic idea of what queries are going to be running against your database.  If you haven't already done so, its now time to start adding indexes to your database.  The catch with index is that there is such a thing as to...


November 3, 2008  11:00 AM

Improving SQL Service Broker Performance



Posted by: Denny Cherry
END CONVERSATION, RECEIVE, Remus Rusanu, SEND, Service Broker, SQL Server 2005, SQL Server 2008, T/SQL

A while back I was talking to a Microsoft Support Engineer and he had mentioned that in a high load Service Broker environment such as ours there can be some impressive performance improvement can be achieved by reusing the service broker sessions. The cost of creating and closing a new...