Friday, July 20, 2007

Summer SQL Teaser #8 Comments And Go

Without running the following two blocks of code what do you think will the output be?


/* code 1

SELECT GETDATE()

GO */

SELECT GETDATE()



/* code 2

SELECT GETDATE()

GO

*/

SELECT GETDATE()

3 comments:

rudy said...

SELECT GETDATE() produces exactly what is expected, provided you allow for the time it takes in between the first SELECT GETDATE() and the second SELECT GETDATE()

what was the point of this teaser?

SQL said...

Rudy,

It is not the select date, it is the GO that will throw an error on the 2nd code piece

Denis

MickyM said...

I don't have 2005 to test with at the moment, but it doesn't throw an error on my SQL 2000 system.