|
|
|
|
Browse by Tags
All Tags » Teaser (RSS)
-
Create this table CREATE TABLE #bla (SomeVal uniqueidentifier) INSERT #bla VALUES ( 'D903D52D-DBFA-4904-9D95-F265152A391F' ) What do you think this will return? SELECT * FROM #bla WHERE SomeVal = 'D903D52D-DBFA-4904-9D95-F265152A391F12345678910' UNION Read More...
|
-
Without running this what do you think will be printed? SET ROWCOUNT 0 DECLARE @ int SET @ = 6 IF @@ROWCOUNT = 1 PRINT 'yes' ELSE PRINT 'no' PRINT @@rowcount Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it! Read More...
|
-
This one is a little sneaky, don’t send me hate mail for it. What does this return? SELECT ISNUMERIC ( '+' ), ISNUMERIC ( '–' ) Copy and paste it into QA/SSMS to verify :-0 Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live 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...
|
-
This should trip up some people..... Without running this code what do you think will LEN and DATALENGTH return? DECLARE @i int SELECT @i = ' 123456789 ' SELECT @i , LEN ( @i ), DATALENGTH ( @i ) Share this post: email it! | bookmark it! | digg it! | Read More...
|
-
Print the @SQL variable without using PRINT DECLARE @SQL varchar ( 49 ) SELECT @SQL = 'Print This Now ' + CONVERT ( VARCHAR ( 30 ), GETDATE ()) --Your Code Here Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it! Read More...
|
-
Without running this code try to guess what the values of @var1 and @var2 will be CREATE TABLE #TeasMeNot ( id int ) DECLARE @var1 int , @var2 int SELECT @var1 = 0 , @var2 = 0 SELECT @var1 = id FROM #TeasMeNot SELECT @var2 = ( SELECT id FROM #TeasMeNot Read More...
|
-
What will happen when you run this? Create Table #Dots ( Data VarChar ( 50 )) Insert Into ... #Dots Values ( 'Huh?' ) --3 dots Insert Into .. #Dots Values ( 'Huh, say what?' ) --2 dots Select * From . #Dots -- 1 dot Drop Table #Dots --look no dots! Share Read More...
|
-
What do you think will be the output? DECLARE @d datetime SET @d = '20071010' SELECT DATEADD (yy, DATEDIFF (yy, 0, @d)+1, -1) Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it! Read More...
|
-
Here is a small teaser, can you guess the output? SELECT d.c-d.b/d.a FROM ( SELECT 1 c,2 b,5 a)d(a,b,c) Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it! Read More...
|
-
What will be the outcome of this script? First we create a table with a total of 6000 bytes Next we increase col2 from 1000 to 2000 bytes, this will give us a total of 7000 bytes Finally we add col3 which has 1000 bytes, this will give us a total of 8000 Read More...
|
-
Hi and welcome to another fascinating SQL summer teaser. Summer it is except in Princeton where it was 50 degrees this week. There was no teaser last week because of a death in the family, I had to go to a wake and a funeral last week. That is why this Read More...
|
-
The teaser for this week is not really a teaser, this time you will have to write some code instead of guessing/knowing. First create this table of numbers SET NOCOUNT ON CREATE TABLE numbers ( num int primary key ) DECLARE @l int SELECT @l = 0 WHILE Read More...
|
|
|
|
|
|