Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sql2008 How to connect db in sql2008 without []

Posted on 2012-04-11
5
Medium Priority
?
152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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 1000 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:Deepak Chauhan
Deepak Chauhan earned 500 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 500 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

730 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