SQL Server Performance

Merry Christmas!

Discussion in 'The Lighter Side of Being a DBA' started by DilliGrg, Dec 22, 2006.

  1. DilliGrg Member

    Wish you all the best and Happy holidays.

  2. MohammedU New Member

    CREATE PROCEDURE HappyHolidays (<br /> @DecorLevel int,<br /> @height int,<br /> @width int<br />) as<br />/* AUTHOR: STEVE KASS, DREW UNIVERSITY */<br />SET NOCOUNT ON<br />select top 0 1 as r, space(@width+4) as s<br />into #Holiday from Northwind..Orders<br /><br />set rowcount @height<br />select identity(int,1,1) as r<br />into #index from Northwind..[Order Details]<br />set rowcount 0<br /><br />insert into #Holiday(r,s)<br />select r, stuff(space(@width/2),cast(@width/2-(1.0*@width*r/@height)/2 as<br />int),1,'/')<br /> + stuff(space(@width/2),cast((1.0*@width*r/@height)/2 as<br />int),1,'')<br />from #index<br />where r &lt; @height*0.8<br /><br />insert into #Holiday(r,s)<br />select r, stuff(space(@width/2),<br /> 1+cast(@width/2-(r*1.0/@height)*(@width/2) as int),<br /> cast((1.0*r/@height)*(@width/3) as int),<br /> replicate('-',cast((r*1.0/@height)*(@width/3)as int)))<br /> + stuff(space(@width/2),<br /> 1+cast((r*1.0/@height)*(@width/6) as int),<br /> cast((1.0*r/@height)*(@width/3) as int),<br /> replicate('-',cast((r*1.0/@height)*(@width/3) as int)))<br />from #index<br />where r = (<br /> select min(r) from #index where r &gt;= @height*0.<img src='/community/emoticons/emotion-11.gif' alt='8)' /><br /><br />declare @a int<br />set @a = charindex('- ',(select s from #Holiday where r &gt;= @height*0.<img src='/community/emoticons/emotion-11.gif' alt='8)' />)<br />insert into #Holiday<br />select r, space(@a-1)+'|'+space(@width-@a-@a-2)+'|'<br />from #index<br />where r &gt;= @height*0.8+1<br />select @a = rand(cast(cast(newid() as binary(<img src='/community/emoticons/emotion-11.gif' alt='8)' />) as int))<br />while @decorLevel &gt; 0 begin<br />set @a = 1<br />while @a &lt; 0.8*@height begin<br /> if rand() &gt; 0.4<br /> update #Holiday<br /> set s = stuff(s,<br /> cast(charindex('/',s)+1+rand()*(charindex('',s)-charindex('/',s)-2)<br />as int),1,'*')<br /> where r = @a<br /> set @a = @a + 1<br />end<br />set @decorLevel = @decorLevel - 1<br />end<br /><br />select s as [Happy Holidays] from #Holiday<br />order by r<br />go<br /><br />exec HappyHolidays 3,20,50<br />exec HappyHolidays 7,40,80<br /><br /><br />Mohammed U.
  3. Madhivanan Moderator

    Wishing Everyone the same<br /><br />The relevent forum, IMO, is Lighter side of being DBA [<img src='/community/emoticons/emotion-1.gif' alt=':)' />]<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail

Share This Page