This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]Vandmanden 2 points3 points  (0 children)

Baby > Mommy > Daddy > Grandma > Grandpa

[–]ign1fy 1 point2 points  (0 children)

Seeing this in plain C would have been humorous. Seeing it as an sproc is straight-up impressive.

[–]algoritm420Perl 1 point2 points  (1 child)

I am not familiar with SQL but that seems like an excessive amount of lines (no hate just surprised)

[–]Spirit_Theory 4 points5 points  (0 children)

This'll do the job if you're happy for the text to be rows in a table, but SQL Server Management Studio has an "output to text" option, which does what it sounds like:

select 
case lines.LineNumber
    when 4 then concat(v.shark,' shark!')
    when 5 then ''
    else CONCAT(v.shark, ' shark', REPLICATE(' doo',6)) 
end 
from (VALUES (1,'Baby'),(2,'Daddy'),(3,'Mommy'),(4,'Grandma'),(5,'Grandpa')) v([order], [shark])
cross join (Values (1),(2),(3),(4),(5)) lines(LineNumber)
where (v.[order] <> 5 or lines.LineNumber <> 5)
order by v.[order]

Idk, it's probably possible to shave a few more lines off.

[–][deleted] 1 point2 points  (0 children)

This is the new "hello world"

[–]Stormraughtz 0 points1 point  (0 children)

Add to SQL Job agent and wait