THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

Browse by Tags

All Tags » Teaser   (RSS)
Showing page 2 of 3 (30 total posts)
  • SQL Teaser: Printing Without Using PRINT

    Print the @SQL variable without using PRINT DECLARE @SQL varchar(49) SELECT @SQL = 'Print This Now ' + CONVERT(VARCHAR(30), GETDATE()) --Your Code Here
    Posted to Denis Gobo (Weblog) by Denis Gobo on November 9, 2007
  • SQL Teaser: Select

    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) --What is the value of @var1 and @var2? SELECT @var1,@var2 DROP TABLE #TeasMeNot  
    Posted to Denis Gobo (Weblog) by Denis Gobo on October 24, 2007
  • Dot Doesn't Make Sense?

    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!
    Posted to Denis Gobo (Weblog) by Denis Gobo on October 18, 2007
  • SQL Teaser: Guess the output

    What do you think will be the output? DECLARE @d datetime SET @d = '20071010' SELECT DATEADD(yy, DATEDIFF(yy, 0, @d)+1, -1)
    Posted to Denis Gobo (Weblog) by Denis Gobo on October 10, 2007
  • SQL Teaser: Guess the output

    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)
    Posted to Denis Gobo (Weblog) by Denis Gobo on October 1, 2007
  • SQL Teaser PASS Special: Table Size

    What will be the outcome of this script?First we create a table with a total of 6000 bytesNext we increase col2 from 1000 to 2000 bytes, this will give us a total of 7000 bytesFinally we add col3 which has 1000 bytes, this will give us a total of 8000 bytes First run these two statements--Total size = 6000CREATE TABLE TestSize (Col1 ...
    Posted to Denis Gobo (Weblog) by Denis Gobo on September 21, 2007
  • Summer SQL Teaser #12 Numeric

    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 teaser will be posted on a Thursday instead of a Friday this week ;-) look at these values ...
    Posted to Denis Gobo (Weblog) by Denis Gobo on August 23, 2007
  • Summer SQL Teaser #11 Missing Dates

    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 @l <= 1000 BEGIN INSERT numbers VALUES(@l) SET @l = @l + 1 END GO Below is a table, ...
    Posted to Denis Gobo (Weblog) by Denis Gobo on August 10, 2007
  • Summer SQL Teaser #10 NULLIF

    Here is a fun teaser. NULLIF will return a null value if the two specified expressions are equivalent.So to give an exampleDECLARE @v varcharSET @v = ' ' SELECT NULLIF(@v,' ')That returned NULL because @v and ' ' are the sameNow run this firstCREATE TABLE #j (n varchar(15))DECLARE @a intSET @a = 1WHILE @a <= 1000 BEGININSERT #jSELECT ...
    Posted to Denis Gobo (Weblog) by Denis Gobo on August 3, 2007
  • Summer SQL Teaser #9 ROLLBACK

    This one is not so much a teaser but it will show you what you can do in case you want to insert data in a logging table after a rollback occursWithout running this try to guess what the counts of the three tables will be after the rollbackCREATE TABLE Test (id int)CREATE TABLE #Test (id int)DECLARE @Test table (id int)BEGIN TRAN   ...
    Posted to Denis Gobo (Weblog) by Denis Gobo on July 27, 2007
Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement