Click here to Skip to main content
12,244,322 members (51,085 online)
Rate this:
 
Please Sign up or sign in to vote.
hi all,

i am trying to change column name in sql2008 from StudentId to SID .
i am using this query :
alter table Student
rename column StudentId to SID
By using this not altered the table column .
so that please any one help to me.
thanks in advance

regarding ,
naresh
Posted 1-May-12 18:07pm
Edited 1-May-12 18:37pm
v3
Comments
walterhevedeich 1-May-12 23:42pm
   
Your syntax is for Oracle, and will not work on SQL Server. I suggest you take a look at the answer below.
satrio_budidharmawan 2-May-12 0:08am
   
The question should be like this : "How to change column name in SQL Server with SQL Query".
Because SQL alone, stand for every Database engine
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The column can be renamed using
SP_RENAME 'Student.StudentId', 'SID ', 'COLUMN'
as explained here
SQL SERVER – How to Rename a Column Name or Table Name[^]
  Permalink  
Comments
walterhevedeich 1-May-12 23:42pm
   
My 5!
VJ Reddy 2-May-12 0:11am
   
Thank you, walterhevedeich.
Unareshraju 1-May-12 23:53pm
   
thank u somuch reddy
by using this i solved my problem
"SP_RENAME 'Student.StudentID','SID'
GO"
VJ Reddy 2-May-12 0:11am
   
You're welcome and thank you for accepting the solution.
Shahin Khorshidnia 2-May-12 9:04am
   
+5
VJ Reddy 2-May-12 9:38am
   
Thank you, Shahin.
Arjun Menon U.K 18-Oct-12 0:00am
   
SP_RENAME 'Student.StudentId', 'SID ', 'COLUMN'

IS there any other way than the query above using any DML statements.. IT will be of great help,Thanks in adv
Member 10018938 22-Jun-14 5:38am
   
change column na,e in use simple query in sql server 2008 r2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

select studentid as sid,sname,... into #temp from student
u just select all the columns and what ever column name u want to rename just give a name beside that column and import into another table .
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 7

exces sp_rename 'Persons.city','c_name', column
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

change column name not use to store procedure please help simple query
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 1 Sep 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100