Wednesday, March 28, 2012
Ok, time to start a war
I've noticed that some folks are adamant that table names should be
singular; others are adamant they should be plural. Myself, I believe in the
plural school. I simply don't understand the argument that a table should be
named singular, as it holds a collection of entities. We have tables of
Customers, Contacts, Addresses, Quotes, Sales, etc. A column is AN attribute
of an entity, a row is AN instance of an entity. During development, when I
populate a list with Customers, the immediate thought is to use the
"Customers" table, not the "Customer" table. I'm interested in someone
convincing me otherwise.Earl (brikshoe@.newsgroups.nospam) writes:
> Trivia perhaps, but this has bothered me for a long time. Over the
> years, I've noticed that some folks are adamant that table names should
> be singular; others are adamant they should be plural. Myself, I believe
> in the plural school. I simply don't understand the argument that a
> table should be named singular, as it holds a collection of entities. We
> have tables of Customers, Contacts, Addresses, Quotes, Sales, etc. A
> column is AN attribute of an entity, a row is AN instance of an entity.
> During development, when I populate a list with Customers, the immediate
> thought is to use the "Customers" table, not the "Customer" table. I'm
> interested in someone convincing me otherwise.
I have a suggestion for a compromise! Let's use the Slovene for the table
names. Then the two camps can meet each other half-way and use the dual
number for table names!
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Earl wrote:
> Trivia perhaps, but this has bothered me for a long time. Over the years,
> I've noticed that some folks are adamant that table names should be
> singular; others are adamant they should be plural. Myself, I believe in t
he
> plural school. I simply don't understand the argument that a table should
be
> named singular, as it holds a collection of entities. We have tables of
> Customers, Contacts, Addresses, Quotes, Sales, etc. A column is AN attribu
te
> of an entity, a row is AN instance of an entity. During development, when
I
> populate a list with Customers, the immediate thought is to use the
> "Customers" table, not the "Customer" table. I'm interested in someone
> convincing me otherwise.
Naming conventions are important but their most important feature is
that they are applied consistently. I can live with either plural or
singular names as long as everyone sticks to the same convention. What
I don't want to see is one table called "Customer" and another in the
same project called "Contacts".
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||ROFL!
And maybe we can also introduce inflections to designate actions. :)
ML
http://milambda.blogspot.com/|||Hear Hear!
I also only like lower case and separate words with _ because you can run
into all sorts of problems if you develop on a case insensitive database and
then go to a case sensitive one. I was part of a big project that had that
exact problem and it convinced me to not use camel case and to use lower
case and underscore instead.
Once you get used to seeing upper case keywords and lower case identifiers
then its fine, bit like moving from ansi 89 to 92 on the join syntax - what
a pain that was!
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1138268495.874429.75640@.f14g2000cwb.googlegroups.com...
> Earl wrote:
>
> Naming conventions are important but their most important feature is
> that they are applied consistently. I can live with either plural or
> singular names as long as everyone sticks to the same convention. What
> I don't want to see is one table called "Customer" and another in the
> same project called "Contacts".
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||Or perhaps use a Macromedia flash encoded object in a table name so that
when you look at it through a graphical tool it gives an animated
representation of what the table is :)
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"ML" <ML@.discussions.microsoft.com> wrote in message
news:29C18C9B-1411-48F8-A023-0111A9938EC8@.microsoft.com...
> ROFL!
> And maybe we can also introduce inflections to designate actions. :)
>
> ML
> --
> http://milambda.blogspot.com/|||Of course that's customizable - per user. And DBA's have a few extra
settings. :)
ML
http://milambda.blogspot.com/|||what!!! you don't like my naming system. LOL I am guilty of that.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1138268495.874429.75640@.f14g2000cwb.googlegroups.com...
> Earl wrote:
>
> Naming conventions are important but their most important feature is
> that they are applied consistently. I can live with either plural or
> singular names as long as everyone sticks to the same convention. What
> I don't want to see is one table called "Customer" and another in the
> same project called "Contacts".
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||There doesn't seem to be any concensus one way or another on this issue of
singular vs. plural naming conventions.
However, when I see table names prefixed with "tbl", I can't help but
cringe, becuase I know there will be more stupidity in store when I start
looking at their choice of keys, T-SQL, and indexes (or lack thereof). :-)
"Earl" <brikshoe@.newsgroups.nospam> wrote in message
news:Oy2upQkIGHA.3192@.TK2MSFTNGP10.phx.gbl...
> Trivia perhaps, but this has bothered me for a long time. Over the years,
> I've noticed that some folks are adamant that table names should be
> singular; others are adamant they should be plural. Myself, I believe in
> the plural school. I simply don't understand the argument that a table
> should be named singular, as it holds a collection of entities. We have
> tables of Customers, Contacts, Addresses, Quotes, Sales, etc. A column is
> AN attribute of an entity, a row is AN instance of an entity. During
> development, when I populate a list with Customers, the immediate thought
> is to use the "Customers" table, not the "Customer" table. I'm interested
> in someone convincing me otherwise.
>|||On Thu, 26 Jan 2006 11:41:25 -0000, "Tony Rogerson"
<tonyrogerson@.sqlserverfaq.com> wrote:
in <#Qswf1mIGHA.3036@.tk2msftngp13.phx.gbl>
>Hear Hear!
>I also only like lower case and separate words with _ because you can run
>into all sorts of problems if you develop on a case insensitive database an
d
>then go to a case sensitive one. I was part of a big project that had that
>exact problem and it convinced me to not use camel case and to use lower
>case and underscore instead.
I'd have to agree with that as it simplifies moving your data in and out of
PostgreSQL. :-)
Stefan Berglund
Monday, February 20, 2012
ODBC In Stored Procedure
I'm trying to get the column names from a table to which I'm connected
through OBDC. I don't want to use linked server. I get my data with
Openrowset.
I found the SQLDescribeCol and SQLColumns ODBC functions.
Can anybody tell me how to use those functions in a SQL Server stored
procedure?
Thanks a lotHi Pumkin,
should work as follows
SELECT colId, name,
FROM dbo.sysObjects
WHERE Id = OBJECT_ID('YourTableName')
ORDER BY ColId
HTH ;-)
Gru, Uwe Ricken
MCP for SQL Server 2000 Database Implementation
GNS GmbH, Frankfurt am Main
http://www.gns-online.de
http://www.memberadmin.de
http://www.conferenceadmin.de
________________________________________
____________
dbdev: http://www.dbdev.org
APP: http://www.AccessProfiPool.de
FAQ: http://www.donkarl.com/AccessFAQ.htm|||Hey,
I should explain myself better... I need to get the column names of a
table given as parameter. There is COLUMN_NAME from INFORMATION_SCHEMA
for SQL Server. The problem is that my table is not on my server and is
not a SQL Server table either. I need to access it through ODBC.
Can anybody help? Thanks|||Pumkin wrote:
> Hey,
> I should explain myself better... I need to get the column names of a
> table given as parameter. There is COLUMN_NAME from INFORMATION_SCHEMA
> for SQL Server. The problem is that my table is not on my server and
> is not a SQL Server table either. I need to access it through ODBC.
> Can anybody help? Thanks
It is not possible to use the ODBC functions you mentioned from a stored
procedure which can only run queries via openrowset.
If the table is in a relational database, then it should be possible to run
a query against that database to get the column names. Without more specific
information, it is impossible to go into details. Maybe you should try a
newsgroup devoted to the rdbms you are linking to.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||Hy Bob,
Thanks for the reply. The database that I am connecting to in not
relational. But I found something now...
It works if I do "select * from table where 1=2"
But I was looking for something more dynamically build.|||Pumkin wrote:
> Hy Bob,
> Thanks for the reply. The database that I am connecting to in not
> relational. But I found something now...
> It works if I do "select * from table where 1=2"
> But I was looking for something more dynamically build.
I'm not sure how that helps you: your t-sql code is not going to be able to
read those column names. I was thinking that you needed your code to somehow
use those column names for something.
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
ODBC in Stored Procedure
I'm trying to get the column names from a table to which I'm connected
through OBDC. I don't want to use linked server. I get my data with
Openrowset.
I found the SQLDescribeCol and SQLColumns ODBC functions.
Can anybody tell me how to use those functions in a SQL Server stored
procedure?
Thanks a lotPumkin (PopClaudia@.gmail.com) writes:
> I'm trying to get the column names from a table to which I'm connected
> through OBDC. I don't want to use linked server. I get my data with
> Openrowset.
> I found the SQLDescribeCol and SQLColumns ODBC functions.
> Can anybody tell me how to use those functions in a SQL Server stored
> procedure?
You can't. Well, you could write an extended stored procedure or an
OLE object that you could call from a stored procedure, and that would
use these functions.
However, it would be more straight forward to query the system catalog
on the remote server directly.
What exactly are you trying to achieve?
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx