TSQL - SimonS Blog on SQL Server Stuff

Browse by Tags

All Tags » TSQL (RSS)

Set based splitting of delimited strings to columns

I recently presented on using CLR in SQL at DevWeek and commented on how TSQL Udfs just don't perform. A common scenario people in the audience were using TSQL Udfs for was splitting delimited strings. One guy asked me afterwards what the best way...

SQL Server 2008 - Whats this abut 30,000 columns?

Its all about Sparse columns and they are a great feature of Katmai Imagine you have a products table, you will have attributes for some products that don't apply to others i.e. cup size applies to bras but not to socks. There are a number of ways...

SQL Server 2008 - Converting binary(hex) values to strings

One of the frequently asked questions in the newsgroups is how do you convert a string representation of a binary value to the equivalent binary value and the reverse. The latter is often required to be able to print out the binary representation. There...
Posted by simonsabin | with no comments

SQL Server 2008 - ISDATE doesn't work with

I really don't understand this. The ISDATE function doesn't work with new date and time types, whats more you can't pass it a string representing a date before 1/1/1753. Try this select ISDATE('1/1/1700') in SQL 2008 it will return 0. Whats odd is that...
Posted by simonsabin | with no comments
Filed under: ,

SQL Server 2008 - Batch inserts and identity columns using MERGE

Performing bulk inserts into a table when the table has an identity column has long bee a difficult challenge for client programming. The difficulty has been getting the identity values that have been generated for the set of data you are saving. It becomes...
Posted by simonsabin | with no comments

Katmai Spatial - First thoughts

I've been doing some work with the Spatial types in Katmai and these are my first thoughts. The first thing is that the data type is the same used by SQL as used in your .Net code. So what does that mean, ยท You use the same methods, which is great from...

How to get the name of the day of date

Do you have a date and you want the day of the week but not the number but the name i.e. Monday, Tuesday etc. Well there are two functions that you can use with dates that can be used to extract a part of the date. One function returns the number and...

What is the position of a row ?

The simple answer is there isn't one. If you insert 1000 rows into a table and then want to get back the 43rd row you inserted you can't. You can read through all rows and return the 43rd one that the database reads from the table but that is not the...
Posted by simonsabin | 1 comment(s)
Filed under: ,

TSQL : How to get messages sent first class

Leo has posted a great tip about how to get messages output in a TSQL batch without waiting until the batch completes. The trick is to use RAISERROR with a level of 0 http://sqlblogcasts.com/blogs/leopasta/archive/2007/07/03/instant-gratification.aspx...
Posted by simonsabin | 1 comment(s)
Filed under: ,

Time dimension - What should the key be?

We are currently implementing a data warehouse and the design of the time dimension was recently being done. Firstly it was agreed that day and time should be split out. Combining the two into one dimension is nuts your dimension would be huge and unworkable...

Using SMO from TSQL

If you are desperate to get your hands on the code I used in the SMO in TSQL demo I did at the usergroup meeting you can download it now from codeplex. http://www.codeplex.com/SMOinTSQL There are 2 projects in there one an SSMS project and one a C# project...

Limit a sql script to only run with SQLCMD turned on

I really like SQLCMDso much so that most of my deployment scripts use SQLCMD. Its got some great features such as :on error exit. Forcing your script to exit when an error occurs. or :r <filename> to read the contents of a file There is one downside...
Posted by simonsabin | with no comments

How to alert on system errors

Alerts in SQL server rely on the error being logged to the event log. Not all system messages are logged which means you can't alert on them. In SQL 2000 you could hack the sysmessages table, however in SQL2005 you can't. To get round this in SQL 2005...
Posted by simonsabin | with no comments

Developer Day 4 Demo - Now available

The demo files associated with are now available. Make sure you read the description first as it includes how to deploy the demo. http://sqlblogcasts.com/files/folders/servicebrokerdemos/entry1472.aspx if (socialButtons!=null) { socialButtons(); } - google_ad_client...

dmvs and CROSS APPLY

In SQL 2005 there is a new feature by which you can extend a result set with the results of another resultset. You might think thats nothing new because thats exactly what a join is, and with the combination of derived tables you have full control, and...
Posted by simonsabin | with no comments
More Posts Next page »