views:

81

answers:

2

I could be not more sorry guys - the question was a very wrong one. As spotted by you the error is due to the fact that a colum with that name does not exists. The error and the post is due to a misalignement between a staging server and a production server. But the error has been detected by your answers, so many, many thanks


The following statement:

select [user] from bookings

is putting me in troubles. Please, note, square brackets has been placed around the reserved keyword. As you can see, unhappily a reserved keyword has been chosen for a column name (an user, of course), but in the previous application running in SQL Server 2000 the query was executed without errors.

Unfortunately in SQL Server 2008 - to which application is ported - the behaviour is different, it complains and emits an error. Altering the database table could be an horrible headache because a lot of changes in db and code must be made. There is a way to execute the query keeping the name of the column?

Thanks!

A: 

What error are you getting. I have just created a bookings table in my copy of SQL2008 and getting no such error with

select [user] from bookings

I also have table named user in a different db and don't have issues

CResults
I get the following message (in italian, but I guess the meaning is clear): Messaggio 207, livello 16, stato 1, riga 2Il nome di colonna 'user' non è valido.
Daniel
Error 207 usually points at the column not existing at all in your table. Does the error only happen in your app or do you get the same error if you run it from the management studio? Also, can you confirm following the upgrade that the column really does exist in the bookings table and hasn't been renamed by the upgrade
CResults
Sei sicuro che la colonna "user" esiste nella tabella "bookings" :-)
CResults
Ora sono sicuro che non esiste, come scritto nel post modificato e a seguito delle domande dubbiose che sono state poste.Una difformità tra due piattaforme mi ha tratto in errore. La colonna che era "user" da una parte è diventata "utente" dall'altra :-(Spiacente per questo stupido post...
Daniel
A: 

2008 is just like before in that it doesn't want you to use reserved names, but I have not had it throwing an error for it.

CREATE TABLE [dbo].[tblUser](
    [userid] [int] IDENTITY(1,1) NOT NULL,
    [user] [nchar](10) NOT NULL,
 CONSTRAINT [PK_tblUser] PRIMARY KEY CLUSTERED 
(
    [userid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

followed by

select [user] from tbluser

Generated no error on execution.

Andrew