Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Parentheses in Table name

Author  Topic 

johnnysgrabb
Starting Member

2 Posts

Posted - 2010-04-12 : 10:07:59
Hi!

I have a table that is namned: u513.TblArtikel(lev)
I need to get a column from this table. eg. One column is named ArtikelID. If I write: u513.TblArtikel[(lev)].ArtikelID in my select statement I get an error.

To make it simpel, if I write

SLECT u513.TblArtikel[(lev)].ArtikelID
FROM u513.TblArtikel[(lev)].ArtikelID
I get "The multi part identifier "u513.TblArtikel[(lev)].ArtikelID" could not be bound.

I know that I dont need to write the name of the table in the select statement but I need it in a bigger inner join statement.

How should I Write to be able to use a table with parentheses in its name?

Thx in advance

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-12 : 10:15:08
enclose the whole table name in square brackets.

If the table is really called : u513.TblArtikel(lev) -- why would you ever????

Then reference it like:

[u513.TblArtikel(lev)]

example

SELECT * FROM [u513.TblArtikel(lev)]



Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

johnnysgrabb
Starting Member

2 Posts

Posted - 2010-04-12 : 15:28:23
Thx for your reply!

I know that its not a good name for a table but I havent created the database...
Got it working now, wrote :
SELECT u513.[TblArtikel(Lev)].ArtikelID
FROM u513.[TblArtikel(Lev)]

Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-04-13 : 03:58:13
Ah. then u513 was the schema name.


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2010-04-13 : 08:26:10
quote:
Originally posted by johnnysgrabb

I know that its not a good name for a table but I havent created the database...

Have they caught the guy who did? Or is he still at large?

________________________________________________
If it is not practically useful, then it is practically useless.
________________________________________________
Go to Top of Page
   

- Advertisement -