June 12, 2009 at 7:39 am
Whilst I've (correctly) answered this question in the spirit it's been asked, it's one of what I feel is an increasing number of questions on this site that I think are badly written. This code doesn't actually run for me. The error is "invalid column 'i'"
It took me a minute to work out why ... whilst I have ddl rights the database I used, someone else had already created a "dbo.t1" table with a single column [a] (probably a previous SQLServerCentral.com question). As a result, the create table statement defaulted to creating me a table under my own login .t1, the insert statements inserted into this table, and the drop is also OK, but the select statement is poor SQL, and actually does "SELECT MAX(i) FROM dbo.t1" ... and there is no column i in this table. These types of questions would be better using temp tables to avoid this.
Viewing post 16 (of 15 total)
You must be logged in to reply to this topic. Login to reply