Solved

sql2008 How to connect db in sql2008 without []

Posted on 2012-04-11
5
146 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

821 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