Solved

sql2008 How to connect db in sql2008 without []

Posted on 2012-04-11
5
144 Views
Last Modified: 2012-08-13
I have a db name satu-My-2030, when I try with T-sql

Use satu-My-2030 - It wont works Instead I must using

Use [satu-My-2030] It works, but how do I avoid from using []??
0
Comment
Question by:motioneye
  • 3
5 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 37831562
Is there any reason you have to avoid using []?
0
 
LVL 25

Assisted Solution

by:Lee Savidge
Lee Savidge earned 250 total points
ID: 37831570
You may need to read this about database identifiers:

http://msdn.microsoft.com/en-us/library/ms175874.aspx
0
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 250 total points
ID: 37831577
Specifically this line is pertinent to you:

When identifiers are used in Transact-SQL statements, the identifiers that do not comply with these rules must be delimited by double quotation marks or brackets.

A hypen does not comply with the rules so you must delimit them.
0
 
LVL 15

Assisted Solution

by:deepakChauhan
deepakChauhan earned 125 total points
ID: 37832225
Brackets are required if your table name, database name, linked server name ,  column names: or any object name in sql server

1 Contain special character or arithmetic operator in database name , linked servername or server name .
2 contain a space: SELECT [column name] FROM table;
3 contain a bracket: SELECT [wt[f], or SELECT [wt]]f]
4 contain a non-alphanumeric symbol like ^ or ! (yes, they can contain those symbols!)
  are reserved keywords like KEY, STATE, RULE, ...

These all are rules of sql server.
0
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 125 total points
ID: 37835511
Use [satu-My-2030] It works, but how do I avoid from using []?

In short, rename it so that the name follows the rules. For example, you might rename it to satuMy2030.

That will help avoid needing brackets.

Tom
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now