Fun with T-SQL
November 15th, 2008
As a tribute to some fairly restrictive .NET design I once fell victim to, I wrote this piece of code:
Use [Database]
Select [Select]
From [From]
Where [Where] = ‘Where’
And [nvarchar(50)] = ‘nvarchar(50)’
And [int] = 1
The CREATE and INSERT statements for the above command:
CREATE TABLE [dbo].[From](
[Id] [int] NOT NULL,
[Where] [nvarchar](50) NOT NULL,
[On] [nvarchar](50) NOT NULL,
[Select] [nvarchar](50) NOT NULL,
[From] [nvarchar](50) NOT NULL,
[int] [int] NOT NULL,
[nvarchar(50)] [nvarchar](50) NOT NULL
)
INSERT INTO [From] ( [Id]
, [Where]
, [On]
, [Select]
, [From]
, [int]
, [nvarchar(50)])
SELECT 1, ‘Where’, ‘On’, ‘:-)’, ‘From’, 1, ‘nvarchar(50)’
Enjoy!
If you enjoyed this post, make sure you subscribe to my RSS feed!
Related posts:
- Ordering Dimensions: Recursion vs Loops in T-SQL
- Moving writeback data in the Fact tables and avoiding problems with changing column names
- Spreading Non-Transactional Data Along Time