Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language MS SQL

Date:04/20/05
Author:AMi
URL:n/a
Comments:2
Info:n/a
Score: (2.00 in 3 votes)
/*25.09.2000 by AMi amiundyvonne@web.de*/ <mailto:amiundyvonne@web.de*/> 
 
DECLARE @beer INT
SELECT @beer=99
nextBeer:
 IF @beer=0 GOTO noBeer
 SELECT CONVERT(VARCHAR,100-@beer)+' bottles of beer on the wall,'
 SELECT CONVERT(VARCHAR,@beer)+' bottles of beer,'
 SELECT 'take one down and pass it around,'
 SELECT @beer = @beer - 1
 GOTO nextBeer
noBeer:
SELECT 'NO MORE BOTTLES OF BEER ON THE WALL'
SELECT 'NO MORE BOTTLES OF BEER'
SELECT 'GO TO THE STORE AND BUY SOME MORE'
SELECT '99 BOTTLES OF BEER'

Download Source | Write Comment

Alternative Versions

Comments

>>  Karl said on 07/20/05 15:27:58

Karl Hi!

your code doesen't work correct. Compare the end of your list with the tamplate. Especially the last 3 lines.

Gre

>>  C said on 09/07/06 12:43:52

C The Line

SELECT CONVERT(VARCHAR,100-@beer)+' bottles of beer on the wall,'

Just needs the "100-" removing from within the convert, otherwise this line counts up and the second part of that line in the song counts down.

and setting nocount on make the result more readable :-)

C
P.s. BTW, the site, nice idea.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: