Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mb25stan2
Starting Member
3 Posts |
Posted - 2010-08-30 : 17:30:59
|
| The company I work for has a naming convention for the sql databases. The begin with a 2 digit number then name. I'm trying to write a simple vbscript to create and restore a database with the name 09company but it appears that sql doesn't like the fact that the database starts with a number. This is even more baffling as there is already a 01company database within the sql instance?Any ideas?ThanksMark |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
mb25stan2
Starting Member
3 Posts |
Posted - 2010-08-30 : 18:07:58
|
| Thanks for replying.In response to your reply why then can the script create any database name other than when I prefix it with a number?I've tried running a simple create command through sqlcmd and get the same problem, no number prefix no problem, number prefix can't create.Mark |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
mb25stan2
Starting Member
3 Posts |
Posted - 2010-08-30 : 18:36:59
|
| serverName = "LOCALHOST\SQLEXPRESS"set cn = createobject("ADODB.Connection")The script is:set cmd = createobject("ADODB.Command")cn.open "Provider=SQLOLEDB.1;Data Source=" & serverName & ";Integrated Security=SSPI;Initial Catalog=Master"cmd.activeconnection = cncmd.commandtext = "exec sp_helpdb" databasename="02company" cmd.commandtext = "CREATE DATABASE " & databasename cmd.CommandTimeout = 60 * 20 cmd.executewscript.echo "create Complete"cn.closeThe error I get is:"incorrect syntax near '02'.I'm new to all this so your help is very much appreciated.ThanksMark |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-31 : 05:54:12
|
quote: Originally posted by mb25stan2 serverName = "LOCALHOST\SQLEXPRESS"set cn = createobject("ADODB.Connection")The script is:set cmd = createobject("ADODB.Command")cn.open "Provider=SQLOLEDB.1;Data Source=" & serverName & ";Integrated Security=SSPI;Initial Catalog=Master"cmd.activeconnection = cncmd.commandtext = "exec sp_helpdb" databasename="02company" cmd.commandtext = "CREATE DATABASE " & databasename cmd.CommandTimeout = 60 * 20 cmd.executewscript.echo "create Complete"cn.closeThe error I get is:"incorrect syntax near '02'.I'm new to all this so your help is very much appreciated.ThanksMark
It is better to use company02 or company_02. Dont name an object starting with a digitMadhivananFailing to plan is Planning to fail |
 |
|
|
naveengopinathasari
Yak Posting Veteran
60 Posts |
Posted - 2010-08-31 : 06:26:27
|
| Try giving with [02Company]Lets unLearn |
 |
|
|
|
|
|