Saturday, February 25, 2012

Column Names - Modifing

Can the column names be change in SQL Express.

I am amist of pulling my hair out here, I have got a scenerio of needing to be able to move data around, my first thought was to have two columns, one for the data and the other for the column name. Once getting into the manipulation of the data, it occurred. MUCH EASIER to modify the column name in the data table rather the data.

Is it possible from VB to change the name of the column in the database table?

Thanks Again

Davids Learning

Use sp_rename

create table test
(
trestId int
)
go

exec sp_rename 'test.trestId','testId','Column'

go

select *
from test

testId
--

|||

Ok

You can call me a dummy here,

Can you explain this a little bit more. I havent done a whole lot with TSQL,

and also, is this in VB?

Very Confused

Davids Learning

|||

No, the stuff in bold is the code you would use from management studio (2005) or query analyzer (2000):

create table test
(
trestId int
)
go

exec sp_rename 'test.trestId','testId','Column'

go

select *
from test

The other stuff was setup to show you how it worked. If you don't know how to execute queries, you might ask for a prod in the right direction in the VB forums:

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=32&SiteID=1

These forums are for how to write TSQL, which is its own language...

No comments:

Post a Comment