Tag Archives: T-SQL

XML Schema Creation in SQL Server 2005

Here’s an interesting approach for creating a quick and dirty schema to get you started with XML. DECLARE @schema xml SET @schema = (SELECT * FROM schema.TABLE FOR XML AUTO, ELEMENTS, XMLSCHEMA(’SchemaName’)) SELECT @schema I don’t have the source, but … Continue reading

Posted in SQL Toolbox | Tagged , , | Leave a comment

Recursive Directory Scripting

Inside source control, I have scripts arranged as follows: Drive:/Base/Database/ Drive:/Base/Database/Functions Drive:/Base/Database/Proc Drive:/Base/Database/Tables Etc.. Each script stored can be run multiple times with no ill effect. For example, a table generation script first checks to see that it exists before … Continue reading

Posted in SQL Server Development, SQL Toolbox | Tagged , , | Leave a comment

Moving Database Logins

Recently we had a database issue, that necessitated us moving logins. Here’s an article I used from Microsoft to help script the logins. The KB is specifically for 2005 -> 2008, but it will also get you login’s out of … Continue reading

Posted in SQL Toolbox | Tagged , , , | Leave a comment

RePost: Database development mistakes made by application developers

Link Personally, I think this should also include database developers operating on too little sleep and/or too close of a deadline.

Posted in SQL Server Development | Tagged | Leave a comment

Enable CLR

This is just one of those things that I always forget how to do. EXEC sp_CONFIGURE ‘SHOW ADVANCED OPTIONS’ , ‘1’ — Let me change it GO RECONFIGURE GO EXEC sp_CONFIGURE ‘CLR ENABLED’ , ‘1’ GO RECONFIGURE GO EXEC sp_CONFIGURE … Continue reading

Posted in SQL Toolbox | Tagged , | Leave a comment

T-SQL Creativity

This article has little to do with useful t-sql applications – since to me, minesweeper is meant for a mouse. However, it really demonstrates a fun use of t-sql. Minesweeper in T-SQL

Posted in Uncategorized | Tagged , | Leave a comment

Hashbytes – VARCHAR vs. VARBINARY Performance

A recent post on sqlservercentral.com got me thinking about Hashbytes recently. I was ignoring the issue of getting a false positive using a hashbyte solution to check for errors, and focused on the performance of the routine. My initial pass … Continue reading

Posted in SQL Server Performance | Tagged , , , , | Leave a comment

First Day of Current Month

SELECT DATEADD( mm, DATEDIFF( mm, 0, GETDATE() ), 0 ) AS FirstOfMonth Since I always manage to get the syntax wrong from memory, above is a SELECT statement that will return the first day of the current month. Edit: As … Continue reading

Posted in SQL Toolbox | Tagged , , | 1 Comment

XML Modification

XML Modification for fun and profit Continue reading

Posted in SQL Server Development | Tagged , , | Leave a comment

XML Nodes Query

A reminder of how the nodes query works inside Microsoft SQL Server. Continue reading

Posted in SQL Server Development, SQL Toolbox | Tagged , | Leave a comment