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
 Changing Name

Author  Topic 

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-04-07 : 01:56:09
Hi,
My question is how can i change the name of a table for exm:- empbonus as emp.bonus

KaShYaP

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-04-07 : 02:04:16
sp_rename empbonus ,[emp.bonus]

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-07 : 02:05:15
use sp_rename

are you sure you want to use name containing dot ? emp.bonus

you will need to enclose the name in bracket when you reference the table [emp.bonus]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-04-07 : 02:18:34
Mr.Khtan
Is there any problem occurs by using a dot between them

KaShYaP
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-07 : 02:26:30
quote:
Originally posted by kashyapsid

Mr.Khtan
Is there any problem occurs by using a dot between them

KaShYaP


Yes. Special characters as re not allowed.
If you use them use withing []

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-07 : 02:27:48
not really a problem it is just you need to use the bracket [ ] with the table name


select *
from [emp.bonus]


instead of just


select *
from emp_bonus



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-04-07 : 02:33:20
select * from [emp.bonus] select*from emp_bonus in both cases the output will be same?


KaShYaP
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-07 : 02:36:30
quote:
Originally posted by kashyapsid

select * from [emp.bonus] select*from emp_bonus in both cases the output will be same?

KaShYaP



In my last post, i am giving an example of using a table name without the dot but underscore emp_bonus instead of emp.bonus

if your table name is emp_bonus, you can reference the table name without using the []. If the table name is emp.bonus, you can't do a "select * from emp.bonus". you will need to use the []
"select * from [emp.bonus]"


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

kashyapsid
Yak Posting Veteran

78 Posts

Posted - 2010-04-07 : 03:29:57
MR.khtan
A sincere Thanks to you for considering

KaShYaP
Go to Top of Page
   

- Advertisement -