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
 altering column names

Author  Topic 

tariq2
Posting Yak Master

125 Posts

Posted - 2011-10-19 : 09:39:31
Hi,

I need to alter column names in the table tijobset.
Both methods below fail and I was wondering why?

Many thanks


1)
alter table tijobset
RENAME COLUMN jobnumber to gldoc;

2)
EXEC sys.sp_rename 'tijobset.jobnumber','gldoc','COLUMN'

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-19 : 09:46:47
sp_rename should work. are you having required access to schema tijobset?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sqlmaster555112
Starting Member

13 Posts

Posted - 2011-10-19 : 11:08:25
Hi Tariq2
If nothing is working try this one
suppose ur table tijobset has columns as value and jobnumber

Select * from tijobset

will give an output like

Value Jobnumber
1 10
2 5
3 8

Now u want to change the name of jobnumber to gldoc

Select Value,jobnumber as [gldoc] into tojobset1 from tojobset

this would provide u with the table tojobset1 with columns as Value and gldoc

Watsay can be tried???? Later change the names of the so called tables back......do reply to this hotfix????

@sqlmaster

http://www.intelcs.com/SQL_Server_Consultant.aspx
Go to Top of Page

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2011-10-19 : 11:27:27
Try this

sp_rename 'tijobset.jobnumber','gldoc','COLUMN'


dev
Go to Top of Page

tariq2
Posting Yak Master

125 Posts

Posted - 2011-10-19 : 13:21:50
Hi guys,

Although there were error messages sp_rename did actually work.
Thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-20 : 00:12:33
what was the error messages?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-10-21 : 03:04:53
quote:
Originally posted by tariq2

Hi guys,

Although there were error messages sp_rename did actually work.
Thank you



It should be a message that says about the change of column name and not the error message

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-21 : 04:41:47
oh...i think its the standard message it gives

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -