Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
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 at 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 at 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 at 1-May-12 23:42pm
   
My 5!
VJ Reddy at 2-May-12 0:11am
   
Thank you, walterhevedeich.
Unareshraju at 1-May-12 23:53pm
   
thank u somuch reddy
by using this i solved my problem
"SP_RENAME 'Student.StudentID','SID'
GO"
VJ Reddy at 2-May-12 0:11am
   
You're welcome and thank you for accepting the solution.
Shahin Khorshidnia at 2-May-12 9:04am
   
+5
VJ Reddy at 2-May-12 9:38am
   
Thank you, Shahin.
Arjun Menon U.K at 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 at 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 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
0 Sergey Alexandrovich Kryukov 450
1 OriginalGriff 220
2 DamithSL 130
3 Dave Kreskowiak 120
4 Suvendu Shekhar Giri 110
0 OriginalGriff 7,645
1 DamithSL 5,614
2 Sergey Alexandrovich Kryukov 5,344
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 29 Nov 2014
Copyright © CodeProject, 1999-2014
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