<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss'><id>tag:blogger.com,1999:blog-6516081340051915164</id><updated>2009-11-14T18:10:49.210+01:00</updated><title type='text'>Fox Tricks</title><subtitle type='html'>Mostly Microsoft SQL Server related tips and tricks.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-8454884319667739201</id><published>2009-06-28T20:43:00.000+01:00</published><updated>2009-07-09T06:43:55.682+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><title type='text'>Going beyond sp_helpindex</title><summary type='text'>Every SQL Server developer and DBA has to use the sp_helpindex from time to time to get some information on the indexes on a table. 

I have 2 major problems with this stored procedure:
 
   All information is concatenated in 1 string
   Not much info on partitioned indexes
 

If I run the following statement:

&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

exec sp_helpindex '</summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/8454884319667739201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=8454884319667739201' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/8454884319667739201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/8454884319667739201'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2009/06/going-beyond-sphelpindex.html' title='Going beyond sp_helpindex'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-5533147623957687323</id><published>2009-06-12T17:04:00.017+01:00</published><updated>2009-07-23T12:30:14.096+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2008'/><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2000'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to determine the default database path in all SQL Server Versions</title><summary type='text'>When you create a database in SQL Server using the "CREATE DATABASE" statement without any options, the database files will be created in some "default" locations.

Many people think this default location is the same as the location of the master database, but this is incorrect, it is possible to alter the location in server properties after installation of the server. (in Management Studio right</summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/5533147623957687323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=5533147623957687323' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/5533147623957687323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/5533147623957687323'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2009/06/how-to-determine-default-database-path.html' title='How to determine the default database path in all SQL Server Versions'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-87963842727192196</id><published>2008-07-08T08:35:00.016+01:00</published><updated>2009-09-21T19:07:45.891+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to create SQL Server temp tables without collation problems</title><summary type='text'>In SQL Server it is possible to create temporary tables which are special tables that are automatically cleaned up when they go out of scope. There are two types of temporary tables, global and local temporary tables.

Global Temporary Tables are visible in all sessions currently connected to the SQL Server instance and only go out of scope when the last session disconnects from the server. It is</summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/87963842727192196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=87963842727192196' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/87963842727192196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/87963842727192196'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2008/07/how-to-properly-create-temp-tables-in.html' title='How to create SQL Server temp tables without collation problems'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-1729528358881686822</id><published>2008-05-09T13:28:00.004+01:00</published><updated>2008-05-14T09:53:19.294+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>How to strip trailing zeros</title><summary type='text'>A client came to me with another string formatting problem. I would never recommend formatting strings in T-SQL, but rather to do formatting on the client side.

The question was to strip trailing zeros from a numeric value stored in a string but retain the decimals when they are not zero. 



   
1.0501needs to show1.0501
1.0500needs to show1.05
1.0000needs to show1



This is easy to do by </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/1729528358881686822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=1729528358881686822' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1729528358881686822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1729528358881686822'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2008/05/how-to-strip-trailing-zeros.html' title='How to strip trailing zeros'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-2358567795429035147</id><published>2007-11-23T10:17:00.000+01:00</published><updated>2007-11-23T12:00:41.592+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>How to make a thread safe insert/update procedure on SQL Server</title><summary type='text'>When developing an application that does a lot of inserts and updates, it is sometimes easier to wrap both statements in one stored procedure. 

This results in a simple procedure that will check if a certain record exists. When no record is found a new one is inserted, when a record is found the values are updated.


We will use the following table script as example to explain the problem:

&lt;!--</summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/2358567795429035147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=2358567795429035147' title='30 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/2358567795429035147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/2358567795429035147'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/11/how-to-make-thread-safe-insertupdate.html' title='How to make a thread safe insert/update procedure on SQL Server'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>30</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-3871988331493020791</id><published>2007-08-10T17:24:00.000+01:00</published><updated>2007-09-18T09:51:46.528+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='Installation'/><category scheme='http://www.blogger.com/atom/ns#' term='Virtual PC'/><title type='text'>Building a small Virtual PC with windows xp and SQL Server 2005 Developer edition</title><summary type='text'>
I love Virtual PC 2007, but I hate how every VPC image I used so far is at least 5GB and easily grows to 10GB. It is hard to keep multiple images active on your machine. So I started looking for a way to reduce the size of an image.

About the only usefull resource I found was the site of http://www.bold-fortune.com. This website contains the log of a guy that deletes windows files one by one </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/3871988331493020791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=3871988331493020791' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/3871988331493020791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/3871988331493020791'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/08/building-small-virtual-pc-with-windows.html' title='Building a small Virtual PC with windows xp and SQL Server 2005 Developer edition'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-2662658677699791350</id><published>2007-08-06T08:27:00.000+01:00</published><updated>2007-08-06T12:57:18.247+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>What to do when you want to drop a FileGroup</title><summary type='text'>I was working on a system to partition tables on SQL Server 2005 which means I was creating database filegroups and database files and I needed to drop my newly created objects regularly to retest my code.

But sometimes it was not possible to drop the filegroups with complaints that the filegroup was not empty. 

After a lot of googling I found that it is possible that statistics are defined on </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/2662658677699791350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=2662658677699791350' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/2662658677699791350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/2662658677699791350'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/08/what-to-do-when-you-want-to-drop.html' title='What to do when you want to drop a FileGroup'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-4292335725954893659</id><published>2007-07-04T19:08:00.000+01:00</published><updated>2007-07-05T15:24:04.262+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>A small update to the sp_help_partition procedure.</title><summary type='text'>One of the flaws in the sp_help_partition function I posted earlier is the lack of information if the partition function is a Range RIGHT or a Range LEFT function.

To make that clearer I added a check on the boundary_value_on_right field from the system tables.

Also added an order by to make the presentation nicer.


&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

SELECT
          </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/4292335725954893659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=4292335725954893659' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/4292335725954893659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/4292335725954893659'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/04/small-update-to-sphelppartition.html' title='A small update to the sp_help_partition procedure.'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-1825051855598347644</id><published>2007-07-02T15:51:00.000+01:00</published><updated>2007-07-02T15:59:25.790+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Zero Padding a numeric value in Transact SQL</title><summary type='text'>A quick one before I go home (and just because I used it 10 minutes ago)...

I zero pad a numeric value like this:

&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

DECLARE @mynumber INT,
        @padding  INT
SELECT @mynumber = 123, 
       @padding = 8
SELECT REPLACE(STR(@mynumber, @padding), ' ', '0')


The result of this example will be


 
00000123



I admit, it is not very </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/1825051855598347644/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=1825051855598347644' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1825051855598347644'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1825051855598347644'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/07/zero-padding-numeric-value-in-transact.html' title='Zero Padding a numeric value in Transact SQL'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-1798986930831067490</id><published>2007-07-02T09:29:00.000+01:00</published><updated>2007-07-05T08:31:14.748+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Logging'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><title type='text'>High Performance writing to XML Log files.</title><summary type='text'>A characteristic of logfiles is the "append" nature. We append new content at the back of the file. When writing to a normal text file this is very easy and fast. 


2007-07-01 13:56:04.313 start process
2007-07-01 13:56:25.837 do something
2007-07-01 13:56:25.853 the end


But when we want to use XML files to write log information things become a little bit more complicated because the xml needs</summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/1798986930831067490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=1798986930831067490' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1798986930831067490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1798986930831067490'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/07/high-performance-writing-to-xml-log.html' title='High Performance writing to XML Log files.'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-1931943807021304464</id><published>2007-06-29T14:41:00.000+01:00</published><updated>2007-06-29T15:17:03.066+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Recognising the SQL Server Version</title><summary type='text'>
Something I often need to do is recognise which SQL Server version I am working on. For example to separate SQL 2000 compatible code from SQL Server 2005 compatible code. 

I'll show you some of the options to get the version number... Starting from the ugliest to the most elegant...

The first option is calling the extended procedure xp_msver


&lt;!-- code formatted by http://manoli.net/</summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/1931943807021304464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=1931943807021304464' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1931943807021304464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/1931943807021304464'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/06/recognising-sql-server-version.html' title='Recognising the SQL Server Version'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-3236775060893826639</id><published>2007-06-26T12:56:00.000+01:00</published><updated>2007-07-05T15:25:24.024+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><title type='text'>Using SET IDENTITY_INSERT as a normal database user in SQL Server 2005.</title><summary type='text'>In earlier versions of Microsoft SQL Server it was impossible to grant "SET IDENTITY_INSERT" rights to a normal user. 
To have permission to do an identity_insert (even as part of a stored procedure) you needed to grant the user ddl 
admin rights which is quite a heavy permission to grant to a normal user.

Luckily this problem can be solved in SQL Server 2005 by using Certificates and code </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/3236775060893826639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=3236775060893826639' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/3236775060893826639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/3236775060893826639'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/06/using-set-identityinsert-as-normal.html' title='Using SET IDENTITY_INSERT as a normal database user in SQL Server 2005.'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-584906069007937525</id><published>2007-06-05T13:26:00.000+01:00</published><updated>2007-06-26T09:02:17.578+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQLCLR'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>a Daylight savings time aware version of a sqlclr xp_getfiledetails procedure.</title><summary type='text'>One of the undocumented extended stored procedures that no longer exists in SQL Server 2005 is xp_getfiledetails.

Of course I am aware that I am not the first one to implement this procedure as a SQLCLR procedure. 

I found implementations on the following locations:

SSIS Junkie Blog by Jamie Thomson
Simple Talk by Greg Larsen


But a bug I noticed in both the versions of the procedure is the </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/584906069007937525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=584906069007937525' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/584906069007937525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/584906069007937525'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/06/daylight-savings-time-aware-version-of.html' title='a Daylight savings time aware version of a sqlclr xp_getfiledetails procedure.'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-6214055483249905565</id><published>2007-05-25T08:21:00.000+01:00</published><updated>2007-05-25T13:31:04.613+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Using a schema collection to validate output of FOR XML RAW</title><summary type='text'>Schema collections are used in SQL Server 2005 to create an xml datatype field that is validated with an XML Schema.

Unfortunately there is an xsd feature that is not implemented very nicely is the processContents="lax" attribute. The attribute processContents is implemented, but where normal xsd supports the values strict, lax and skip. The sql server schema collection parser only supports </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/6214055483249905565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=6214055483249905565' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/6214055483249905565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/6214055483249905565'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/05/using-schema-collection-to-validate.html' title='Using a schema collection to validate output of FOR XML RAW'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-131330938040734930</id><published>2007-05-24T09:49:00.000+01:00</published><updated>2007-05-24T10:23:23.223+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Wouldn't it be usefull if sp_who showed the query the user is running.</title><summary type='text'>I can't remember the number of times I have run sp_who2 and then dbcc inputbuffer (##) to quickly check out blocking problems. Wouldn't it be usefull if this information was included in sp_who.

Well, with SQL Server 2005 we can finally do this thanks to the power of the function sys.dm_exec_sql_text(). All I really had to change to sp_who2 was adding "OUTER apply sys.dm_exec_sql_text(</summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/131330938040734930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=131330938040734930' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/131330938040734930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/131330938040734930'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/05/wouldnt-it-be-usefull-if-spwho-showed.html' title='Wouldn&apos;t it be usefull if sp_who showed the query the user is running.'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-4277265222771364092</id><published>2007-05-22T08:27:00.000+01:00</published><updated>2007-05-24T10:22:00.850+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Management Studio'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><title type='text'>Fix SQL Server management studio Ctrl+Tab annoyance</title><summary type='text'>In SQL Server 2000 Query analyzer hitting Ctrl+Tab would advance you one query window in the list of open query windows. Unfortunately In Sql Server Management Studio this will display the default Visual Studio Tab overview window. This window has one huge flaw and that is that it only displays the first 25 characters of the description of the open window. Which results in the Case of SQL Server </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/4277265222771364092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=4277265222771364092' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/4277265222771364092'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/4277265222771364092'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/05/fix-sql-server-management-studio.html' title='Fix SQL Server management studio Ctrl+Tab annoyance'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-7506800146530377110</id><published>2007-05-21T10:32:00.000+01:00</published><updated>2007-07-05T14:23:43.482+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server 2005'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Why is viewing a partitioned table layout so difficult</title><summary type='text'>For some reason the Microsoft SQL Server developers decided not to provide any tools to see how a partitioned table is built. Since it is quite important information I wrote a little sp_help_partition TSQL stored procedure to give an overview. There is an optional object parameter which allows you to filter on a specific partitioned table, or shows you all the partitions in the system. 

The </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/7506800146530377110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=7506800146530377110' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/7506800146530377110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/7506800146530377110'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/05/why-is-viewing-partitioned-table-layout.html' title='Why is viewing a partitioned table layout so difficult'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6516081340051915164.post-4396043833072768249</id><published>2007-05-16T11:06:00.000+01:00</published><updated>2007-06-05T13:24:28.963+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='TSQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL Server'/><title type='text'>Fix the user/login sid mismatch when restoring a SQL Server Database on a different server.</title><summary type='text'>When you take a backup of a SQL Server database one of the tables that is saved in the backup is called "sysusers". This table is used to link a server login to a database user. To do this, SQL Server links the "sid" field of the sysusers table to the "sid" field of the syslogins table in the master database.


&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

select name, sid from </summary><link rel='replies' type='application/atom+xml' href='http://foxtricks.blogspot.com/feeds/4396043833072768249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.blogger.com/comment.g?blogID=6516081340051915164&amp;postID=4396043833072768249' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/4396043833072768249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6516081340051915164/posts/default/4396043833072768249'/><link rel='alternate' type='text/html' href='http://foxtricks.blogspot.com/2007/05/fix-userlogin-mismatch-problems-when.html' title='Fix the user/login sid mismatch when restoring a SQL Server Database on a different server.'/><author><name>Filip De Vos</name><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08374857385436639335'/></author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></entry></feed>