Thursday, March 29, 2012

Database naming convention

Is there database, tables, columns naming convention that I should follow
when I build some information system proposed from Microsoft?
Thanks in advanced
AdnanThere have been many discussions regarding this.
http://groups-beta.google.com/group...ming+convention
-oj
"Adnan Hebibovic" <adnan.hebibovic@.community.nospam> wrote in message
news:et0c85YFFHA.3732@.tk2msftngp13.phx.gbl...
> Is there database, tables, columns naming convention that I should follow
> when I build some information system proposed from Microsoft?
> Thanks in advanced
> Adnan
>|||Yes I know that oj but i will repeat myselft ... "from Microsoft".
"oj" <nospam_ojngo@.home.com> wrote in message
news:OmBDpEZFFHA.3728@.TK2MSFTNGP14.phx.gbl...
> There have been many discussions regarding this.
> http://groups-beta.google.com/group...ming+convention
>
> --
> -oj
>
> "Adnan Hebibovic" <adnan.hebibovic@.community.nospam> wrote in message
> news:et0c85YFFHA.3732@.tk2msftngp13.phx.gbl...
>|||Look up the ISO-11179 Standards first.
I have a new book, SQL PROGRAMMING STYLE, due out the middle of this
year that deals with this topic.
I bothered to research readability, typography, industry standards,
etc. I also get into some common design flaws, heuristics, software
metrics, etc.
I am hoping that people will pick it up and use it as a guide in their
shops. Even if they don't like it, they will have a single set of
rules. And they can yell at me :)|||Thanks
"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1108827223.033936.154350@.o13g2000cwo.googlegroups.com...
> Look up the ISO-11179 Standards first.
> I have a new book, SQL PROGRAMMING STYLE, due out the middle of this
> year that deals with this topic.
> I bothered to research readability, typography, industry standards,
> etc. I also get into some common design flaws, heuristics, software
> metrics, etc.
> I am hoping that people will pick it up and use it as a guide in their
> shops. Even if they don't like it, they will have a single set of
> rules. And they can yell at me :)
>sql

Database Naming

am doing some testing on a database created by the programming dept of the
company, they named the database '123v10'.
When I run some queries (mostly admin stuff, checking the fragmentation,
space used by the data and log files, etc) in the Query Analyzer, I often
get the error message:
Line 1: Incorrect syntax near '123'.
My guess is that SQL doesn't particularly like database names that start
with numbers, am I correct? If so, will this create any real problems down
the line? I think we are at an early enough stage that the database could
be renamed if this would help.
TIA,
Nancy L> My guess is that SQL doesn't particularly like database names that start
> with numbers, am I correct? If so, will this create any real problems
> down
> the line? I think we are at an early enough stage that the database could
> be renamed if this would help.
Yes, you are correct. However, it should not cause problems if you code
defensively (which you should be doing anyways). The problem is that the
creator of the name did not follow the rules for regular identifiers. If
you don't follow the rules, then you must take extra steps to properly
delimit the identifier name (this includes all object names - databases,
triggers, procedures, tables, etc.). Obviously, the easiest approach is to
follow the rules.|||"Scott Morris" <bogus@.bogus.com> wrote in message
news:eUt9vPN$FHA.360@.TK2MSFTNGP09.phx.gbl...
> Yes, you are correct. However, it should not cause problems if you code
> defensively (which you should be doing anyways). The problem is that the
> creator of the name did not follow the rules for regular identifiers. If
> you don't follow the rules, then you must take extra steps to properly
> delimit the identifier name (this includes all object names - databases,
> triggers, procedures, tables, etc.). Obviously, the easiest approach is
> to follow the rules.
>
To add to that. Ensure that you use square brackets [ ] whenever you
reference the db name.
Rick Sawtell|||You may get it to work by using brackets around the db name like [123xxx],
however, somewhere down the road there will perhaps be a query or
application that will choke on it. It would be best to nip it in the bud
now.
"Nancy Lytle" <word_diva@.hotmail.com> wrote in message
news:O0YWoDN$FHA.216@.TK2MSFTNGP15.phx.gbl...
> am doing some testing on a database created by the programming dept of the
> company, they named the database '123v10'.
> When I run some queries (mostly admin stuff, checking the fragmentation,
> space used by the data and log files, etc) in the Query Analyzer, I often
> get the error message:
> Line 1: Incorrect syntax near '123'.
> My guess is that SQL doesn't particularly like database names that start
> with numbers, am I correct? If so, will this create any real problems
> down
> the line? I think we are at an early enough stage that the database could
> be renamed if this would help.
> TIA,
> Nancy L
>

database naming

Hello Group,
where does it talk about naming databases in the books online? I thought
that a database name could not have a dash "-" in the name?
Rich
The topic is "Identifiers"
http://msdn2.microsoft.com/en-us/library/ms175874(SQL.90).aspx .See the
section "Rules for Regular Identifiers".
The only way you can includ special characters like a dash is to delimit the
name with [ ] or qoutes. See the topic "Delimited Identifiers" for more
details.
-- This fails
create database my-database
-- This works
create database [my-database]
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"Rich" <Rich@.discussions.microsoft.com> wrote in message
news:52512AC5-DADA-4C44-83AB-D9C5A635A7B9@.microsoft.com...
> Hello Group,
> where does it talk about naming databases in the books online? I thought
> that a database name could not have a dash "-" in the name?
> Rich
|||Hello Gail,
here is the command I am running in the QA:
backup log intrel-dev with truncate_only
and the error I get:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '-'.
I suspect that the database name cannot have the dash in it.
Rich
"Gail Erickson [MS]" wrote:

> The topic is "Identifiers"
> http://msdn2.microsoft.com/en-us/library/ms175874(SQL.90).aspx .See the
> section "Rules for Regular Identifiers".
> The only way you can includ special characters like a dash is to delimit the
> name with [ ] or qoutes. See the topic "Delimited Identifiers" for more
> details.
> -- This fails
> create database my-database
> -- This works
> create database [my-database]
> --
> Gail Erickson [MS]
> SQL Server Documentation Team
> This posting is provided "AS IS" with no warranties, and confers no rights
> "Rich" <Rich@.discussions.microsoft.com> wrote in message
> news:52512AC5-DADA-4C44-83AB-D9C5A635A7B9@.microsoft.com...
>
>
|||Did you try delimiting the name with [ ] or qoutes? As in, backup log
[intrel-dev] with truncate_only
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"Rich" <Rich@.discussions.microsoft.com> wrote in message
news:059836F7-2E73-4340-BC3C-3FE3E4B3AC7D@.microsoft.com...[vbcol=seagreen]
> Hello Gail,
> here is the command I am running in the QA:
> backup log intrel-dev with truncate_only
> and the error I get:
> Server: Msg 170, Level 15, State 1, Line 1
> Line 1: Incorrect syntax near '-'.
> I suspect that the database name cannot have the dash in it.
> Rich
> "Gail Erickson [MS]" wrote:

database naming

Hello Group,
where does it talk about naming databases in the books online? I thought
that a database name could not have a dash "-" in the name?
RichThe topic is "Identifiers"
http://msdn2.microsoft.com/en-us/library/ms175874(SQL.90).aspx .See the
section "Rules for Regular Identifiers".
The only way you can includ special characters like a dash is to delimit the
name with [ ] or qoutes. See the topic "Delimited Identifiers" for more
details.
-- This fails
create database my-database
-- This works
create database [my-database]
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"Rich" <Rich@.discussions.microsoft.com> wrote in message
news:52512AC5-DADA-4C44-83AB-D9C5A635A7B9@.microsoft.com...
> Hello Group,
> where does it talk about naming databases in the books online? I thought
> that a database name could not have a dash "-" in the name?
> Rich|||Hello Gail,
here is the command I am running in the QA:
backup log intrel-dev with truncate_only
and the error I get:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '-'.
I suspect that the database name cannot have the dash in it.
Rich
"Gail Erickson [MS]" wrote:

> The topic is "Identifiers"
> http://msdn2.microsoft.com/en-us/library/ms175874(SQL.90).aspx .See the
> section "Rules for Regular Identifiers".
> The only way you can includ special characters like a dash is to delimit t
he
> name with [ ] or qoutes. See the topic "Delimited Identifiers" for mo
re
> details.
> -- This fails
> create database my-database
> -- This works
> create database [my-database]
> --
> Gail Erickson [MS]
> SQL Server Documentation Team
> This posting is provided "AS IS" with no warranties, and confers no rights
> "Rich" <Rich@.discussions.microsoft.com> wrote in message
> news:52512AC5-DADA-4C44-83AB-D9C5A635A7B9@.microsoft.com...
>
>|||Did you try delimiting the name with [ ] or qoutes? As in, backup log
[intrel-dev] with truncate_only
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"Rich" <Rich@.discussions.microsoft.com> wrote in message
news:059836F7-2E73-4340-BC3C-3FE3E4B3AC7D@.microsoft.com...[vbcol=seagreen]
> Hello Gail,
> here is the command I am running in the QA:
> backup log intrel-dev with truncate_only
> and the error I get:
> Server: Msg 170, Level 15, State 1, Line 1
> Line 1: Incorrect syntax near '-'.
> I suspect that the database name cannot have the dash in it.
> Rich
> "Gail Erickson [MS]" wrote:
>

database naming

Hello Group,
where does it talk about naming databases in the books online? I thought
that a database name could not have a dash "-" in the name?
RichThe topic is "Identifiers"
http://msdn2.microsoft.com/en-us/library/ms175874(SQL.90).aspx .See the
section "Rules for Regular Identifiers".
The only way you can includ special characters like a dash is to delimit the
name with [ ] or qoutes. See the topic "Delimited Identifiers" for more
details.
-- This fails
create database my-database
-- This works
create database [my-database]
--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"Rich" <Rich@.discussions.microsoft.com> wrote in message
news:52512AC5-DADA-4C44-83AB-D9C5A635A7B9@.microsoft.com...
> Hello Group,
> where does it talk about naming databases in the books online? I thought
> that a database name could not have a dash "-" in the name?
> Rich|||Hello Gail,
here is the command I am running in the QA:
backup log intrel-dev with truncate_only
and the error I get:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '-'.
I suspect that the database name cannot have the dash in it.
Rich
"Gail Erickson [MS]" wrote:
> The topic is "Identifiers"
> http://msdn2.microsoft.com/en-us/library/ms175874(SQL.90).aspx .See the
> section "Rules for Regular Identifiers".
> The only way you can includ special characters like a dash is to delimit the
> name with [ ] or qoutes. See the topic "Delimited Identifiers" for more
> details.
> -- This fails
> create database my-database
> -- This works
> create database [my-database]
> --
> Gail Erickson [MS]
> SQL Server Documentation Team
> This posting is provided "AS IS" with no warranties, and confers no rights
> "Rich" <Rich@.discussions.microsoft.com> wrote in message
> news:52512AC5-DADA-4C44-83AB-D9C5A635A7B9@.microsoft.com...
> > Hello Group,
> >
> > where does it talk about naming databases in the books online? I thought
> > that a database name could not have a dash "-" in the name?
> >
> > Rich
>
>|||Did you try delimiting the name with [ ] or qoutes? As in, backup log
[intrel-dev] with truncate_only
--
Gail Erickson [MS]
SQL Server Documentation Team
This posting is provided "AS IS" with no warranties, and confers no rights
"Rich" <Rich@.discussions.microsoft.com> wrote in message
news:059836F7-2E73-4340-BC3C-3FE3E4B3AC7D@.microsoft.com...
> Hello Gail,
> here is the command I am running in the QA:
> backup log intrel-dev with truncate_only
> and the error I get:
> Server: Msg 170, Level 15, State 1, Line 1
> Line 1: Incorrect syntax near '-'.
> I suspect that the database name cannot have the dash in it.
> Rich
> "Gail Erickson [MS]" wrote:
>> The topic is "Identifiers"
>> http://msdn2.microsoft.com/en-us/library/ms175874(SQL.90).aspx .See the
>> section "Rules for Regular Identifiers".
>> The only way you can includ special characters like a dash is to delimit
>> the
>> name with [ ] or qoutes. See the topic "Delimited Identifiers" for more
>> details.
>> -- This fails
>> create database my-database
>> -- This works
>> create database [my-database]
>> --
>> Gail Erickson [MS]
>> SQL Server Documentation Team
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights
>> "Rich" <Rich@.discussions.microsoft.com> wrote in message
>> news:52512AC5-DADA-4C44-83AB-D9C5A635A7B9@.microsoft.com...
>> > Hello Group,
>> >
>> > where does it talk about naming databases in the books online? I
>> > thought
>> > that a database name could not have a dash "-" in the name?
>> >
>> > Rich
>>

Database Names

Hi Everyone,
I've got Windows SharePoint Services installed and it uses a database called
STS_svr-apps-1_1414639615
I'm trying to back up this database from the QSQL command line tool.
However when I try to run the backup, I get the following error:
1> BACKUP DATABASE STS_svr-apps-1_1414639615 TO DISK
'D:\ShareBack\Backup.bak'
2> GO
Msg 170, Level 15, State 1, Server SVR-APPS-1\SHAREPOINT, Line 1
Line 1: Incorrect syntax near '-'.
1>
Thinking it might be an issue with the name I enclosed it in single quotes:
1> BACKUP DATABASE 'STS_svr-apps-1_1414639615' TO DISK
'D:\ShareBack\Backup.bak'
2> GO
Msg 170, Level 15, State 1, Server SVR-APPS-1\SHAREPOINT, Line 1
Line 1: Incorrect syntax near 'STS_svr-apps-1_1414639615'.
1>
Yet I still get the same error!
Then I tried to just use the database:
1> use STS_svr-apps-1_1414639615
2> go
Msg 911, Level 16, State 1, Server SVR-APPS-1\SHAREPOINT, Line 1
Could not locate entry in sysdatabases for database 'STS_svr'. No entry
found
with that name. Make sure that the name is entered correctly.
1>
Again I tried to using quotation marks, another error:
1> use 'STS_svr-apps-1_1414639615'
2> GO
Msg 170, Level 15, State 1, Server SVR-APPS-1\SHAREPOINT, Line 1
Line 1: Incorrect syntax near 'STS_svr-apps-1_1414639615'.
1> quit
If I do:
SELECT name
FROM master..sysdatabases
ORDER BY name
It lists:
master
model
msdb
STS_Config
STS_svr-apps-1_1414639615
tempdb
From this I can only assume MSDE doesn't support having '-' in a database
name?
Can someone suggest a way around this?
Thanks
Chris Moon
hi Chris,
> From this I can only assume MSDE doesn't support having '-' in a
> database name?
>
SQL Server (and MSDE) support this kind of identifier.. executing
SET NOCOUNT ON
SELECT @.@.VERSION
GO
CREATE DATABASE [STS_svr-apps-1_1414639615];
GO
USE [STS_svr-apps-1_1414639615];
GO
USE master ;
GO
DROP DATABASE [STS_svr-apps-1_1414639615];
reports
Microsoft SQL Server 2000 - 8.00.2162 (Intel X86)
Sep 30 2005 19:59:14
Copyright (c) 1988-2003 Microsoft Corporation
Desktop Engine on Windows NT 5.1 (Build 2600: Service Pack 2)
The CREATE DATABASE process is allocating 0.75 MB on disk
'STS_svr-apps-1_1414639615'.
The CREATE DATABASE process is allocating 0.49 MB on disk
'STS_svr-apps-1_1414639615_log'.
Deleting database file 'C:\Programmi\Microsoft SQL
Server\MSSQL$MSDE2K\Data\STS_svr-apps-1_1414639615_log.LDF'.
Deleting database file 'C:\Programmi\Microsoft SQL
Server\MSSQL$MSDE2K\Data\STS_svr-apps-1_1414639615.mdf'.
http://msdn.microsoft.com/library/de...on_03_6e9e.asp
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.16.0 - DbaMgr ver 0.61.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Many thanks Andrea, it worked perfectly.
Thanks again.
Chris Moon
"Andrea Montanari" <andrea.sqlDMO@.virgilio.it> wrote in message
news:43ml8mF1o772rU1@.individual.net...
> hi Chris,
> SQL Server (and MSDE) support this kind of identifier.. executing
> SET NOCOUNT ON
> SELECT @.@.VERSION
> GO
> CREATE DATABASE [STS_svr-apps-1_1414639615];
> GO
> USE [STS_svr-apps-1_1414639615];
> GO
> USE master ;
> GO
> DROP DATABASE [STS_svr-apps-1_1414639615];
> reports
> ----
> Microsoft SQL Server 2000 - 8.00.2162 (Intel X86)
> Sep 30 2005 19:59:14
> Copyright (c) 1988-2003 Microsoft Corporation
> Desktop Engine on Windows NT 5.1 (Build 2600: Service Pack 2)
> The CREATE DATABASE process is allocating 0.75 MB on disk
> 'STS_svr-apps-1_1414639615'.
> The CREATE DATABASE process is allocating 0.49 MB on disk
> 'STS_svr-apps-1_1414639615_log'.
> Deleting database file 'C:\Programmi\Microsoft SQL
> Server\MSSQL$MSDE2K\Data\STS_svr-apps-1_1414639615_log.LDF'.
> Deleting database file 'C:\Programmi\Microsoft SQL
> Server\MSSQL$MSDE2K\Data\STS_svr-apps-1_1414639615.mdf'.
> http://msdn.microsoft.com/library/de...on_03_6e9e.asp
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.16.0 - DbaMgr ver 0.61.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
sql

Database name with point in it (mail.archive.mdf) not recognised in query analyser of SQL

Apparently the query analyser of sql server does not recognise a
database with a point in it, like
mail.archive.mdf

I receive the following error when I use it:

Server: Msg 911, Level 16, State 1, Line 1
Could not locate entry in sysdatabases for database 'mail'. No entry
found with that name. Make sure that the name is entered correctly.

Please help, thanks
Premselect * from master..sysdatabases
where name ='mail.archive'

mdf is not part of the name

Denis the SQL Menace
http://sqlservercode.blogspot.com/

Prem wrote:
> Apparently the query analyser of sql server does not recognise a
> database with a point in it, like
> mail.archive.mdf
> I receive the following error when I use it:
> Server: Msg 911, Level 16, State 1, Line 1
> Could not locate entry in sysdatabases for database 'mail'. No entry
> found with that name. Make sure that the name is entered correctly.
> Please help, thanks
> Prem|||Prem (premmetje@.zonnet.nl) writes:
> Apparently the query analyser of sql server does not recognise a
> database with a point in it, like
> mail.archive.mdf
> I receive the following error when I use it:
> Server: Msg 911, Level 16, State 1, Line 1
> Could not locate entry in sysdatabases for database 'mail'. No entry
> found with that name. Make sure that the name is entered correctly.

Need to use brackets or double quotes for identifiers with characters
that are not identifier characters normally:

USE [mail.archive.mdf]

--
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