March 29, 2004 at 11:26 pm
Hi,
I am using a batch file to create a database, it works fine with database names like "march_30", "march30". but when i try to create the db name as "march-30", its throwing me with error stating that "incorrect syntax near"-".
When searched the database naming conventions in net i end up with no results..
can anybody help me out of this....
Here's my batch file code:
*****************************************************
@echo OFF
cls
IF [%str2%] == [%1] goto errPara
IF [%str2%] == [%2] goto errPara
IF [%str2%] == [%3] goto errPara
echo Creating Database %2
osql -S%1 -U%3 -P%4 -Q"CREATE DATABASE %2" -n
goto endPara
:errPara
echo "Usage : CreateDB <ServerName> <DBName> <Login> <Pwd>"
:endPara
@echo ON
*****************************************************
Thanks in advance,
Annaraj.
March 30, 2004 at 1:58 am
Hello,
I am not sure about the batch file, but SQL Server won't allow you to "CREATE TABLE March-30". It will allow you to "CREATE TABLE [March-30]".
The - means subtract so you have to use [ ] to tell SQL Server that is a name and not subtract one thing from another. I don't use any non alpha-numeric characters, except _ , in naming any of my tables or columns. Without the other non alpha-numeric characters I don't have to remeber to use the [ ] around my column or table names. Just one less thing to remember for me.
Hope this helps,
Chuck
March 31, 2004 at 9:14 am
Although this is a tangent, I thought I'd share this. Microsoft lists the maximum number of databases per instance as 32,767 (BOL: "Maximum Capacity Specifications") but I did a little test on a development box (lots of HD Gb, 4 Gb RAM, 4 proc) and batch-created databases in a loop. Each db was sequentially named and was only 1 Mb data, 1 Mb log. I believe the magic number was ~1,535 before SQL Server said "I don't think so." Dropping 10 allowed 10 more to be created but 1,535 was the wall. I still had plenty of HD space left but I don't recall how much RAM was consumed.
Take it for what it's worth and I'm certainly not claiming to be the best tester in the world. That's just what I ran into with the environment I tested on.
Cheers,
Ken
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply