Is the coding practice poor to have a SQL table containing a column with the same name?

advertisements

Example:

CREATE TABLE ErrorNumber
(
     ErrorNumber int,
     ErrorText varchar(255),
)

This can result in queries that look like:

SELECT ErrorNumber FROM ErrorNumber WHERE ErrorNumber=10


I'm assuming that ErrorNumber as a column in the table is a primary key? In this case you could name the table column ErrorNumberID.

I don't know about it being a poor coding practice, but I can't imagine it is doing anything for readability. The example you provided is great at showing how confusing the queries can end up being.

The other thing I'm not sure of is if this (column names being the same as table names) would cause an error? I'm sure it varies from vendor to vendor.