Solved

sql2008 How to connect db in sql2008 without []

Posted on 2012-04-11
5
141 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
Comment Utility
Is there any reason you have to avoid using []?
0
 
LVL 25

Assisted Solution

by:Lee Savidge
Lee Savidge earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

762 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

8 Experts available now in Live!

Get 1:1 Help Now