Browse by Tags

Today's teaser is very simple First create this table CREATE TABLE #Tran ( TranCountDefault int DEFAULT ( @@TranCount ), TranCountPassedIn int ) As you can see that table has two columns, one column has a default of @@TRANCOUNT. Now run this piece of Read More...

Take a look at this code, will the select return anything or not? Look at the subquery and notice that there is no FROM there. USE tempdb GO CREATE TABLE TestQuery ( TestID int ) GO SELECT * FROM information_schema.columns WHERE column_name =( SELECT Read More...

You have a table where hours are stores as integers and you need to display it in weeks, days and hours If you have the following table CREATE TABLE #Hours (hours int) INSERT INTO #Hours SELECT 5 UNION ALL SELECT 55 UNION ALL SELECT 125 UNION ALL SELECT Read More...

This teaser was posted by my friend George on Tek Tips and I am posting it here after I asked for his permission. the main reason I am posting it here is because I want to get some opinions from the experts. Take a look at these two queries If 1 / 0 = Read More...

It has been a while since my last teaser but here we go What do you think the following returns? SELECT CONVERT ( datetime , '1/1/1' ) - CONVERT ( datetime , 1 ) + CONVERT ( datetime , 0 ) How about this on SQL Server 2008 SELECT CONVERT ( datetime2 , Read More...