Home > Archive > MS SQL Server > July 2005 > Changing Field/Column Name









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Changing Field/Column Name
childofthe1980s

2005-07-22, 11:23 am

Hello:

I'm working on a Crystal report for a client and, in order for it to work
without errors, I have to change the name of a field (column) in a table.
You see, the field name is two words called "[Print Count]". The space
between these two words, believe it or not, causes errors in my report.

So, I took out the space in this field so that the field name reads
"PrintCount". That fixed my report.

Well, unfortunately, doing this caused problems elsewhere as this name
change did not update (filter to) a SQL View that a user needs in order to
conduct his daily business activities. So, I had to go back and reverse what
I did and add that space back in.

I really did not think that changing the name of a field would cause issues.
But, like I said, changing the name in this table did not update the View
that is based on this table and other tables.

How do I change this field name to be without this space and have this
change update everywhere else effectively in the database including in this
View? I tried to change it subsequently in the View but could not figure out
how to do so.

Any insights would be appreciated!

Thanks!

childofthe1980s
Tibor Karaszi

2005-07-22, 1:23 pm

> But, like I said, changing the name in this table did not update the View
> that is based on this table and other tables.


Correct. This is by design.


> How do I change this field name to be without this space and have this
> change update everywhere else effectively in the database including in this
> View?


There might exist some tools that keep control of all your objects and dependencies that can handle
this for you. There's nothing built into SQL Server or any of the tools that comes with SQL Server.


> I tried to change it subsequently in the View but could not figure out
> how to do so.


ALTER VIEW. Or, of you did SELECT * (horror), you could have used sp_refreshview.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/

Blog: http:// solidqualitylearning
.com/blogs/tibor/



"childofthe1980s" < childofthe1980s@disc
ussions.microsoft.com> wrote in message
news:D2FF25C0-D581-4027-BA45- E2D5CC40D597@microso
ft.com...
> Hello:
>
> I'm working on a Crystal report for a client and, in order for it to work
> without errors, I have to change the name of a field (column) in a table.
> You see, the field name is two words called "[Print Count]". The space
> between these two words, believe it or not, causes errors in my report.
>
> So, I took out the space in this field so that the field name reads
> "PrintCount". That fixed my report.
>
> Well, unfortunately, doing this caused problems elsewhere as this name
> change did not update (filter to) a SQL View that a user needs in order to
> conduct his daily business activities. So, I had to go back and reverse what
> I did and add that space back in.
>
> I really did not think that changing the name of a field would cause issues.
> But, like I said, changing the name in this table did not update the View
> that is based on this table and other tables.
>
> How do I change this field name to be without this space and have this
> change update everywhere else effectively in the database including in this
> View? I tried to change it subsequently in the View but could not figure out
> how to do so.
>
> Any insights would be appreciated!
>
> Thanks!
>
> childofthe1980s


Armando Prato

2005-07-22, 1:23 pm



Is the view referencing the column name directly? If so, you'd need to
change it there too. If you're
doing a SELECT * on the table within the view, then run sp_refreshview to
update the view metadata.

For columns that have spaces, put brackets around them. ie select [print
count] from mytable

"childofthe1980s" < childofthe1980s@disc
ussions.microsoft.com> wrote in
message news:D2FF25C0-D581-4027-BA45- E2D5CC40D597@microso
ft.com...
> Hello:
>
> I'm working on a Crystal report for a client and, in order for it to work
> without errors, I have to change the name of a field (column) in a table.
> You see, the field name is two words called "[Print Count]". The space
> between these two words, believe it or not, causes errors in my report.
>
> So, I took out the space in this field so that the field name reads
> "PrintCount". That fixed my report.
>
> Well, unfortunately, doing this caused problems elsewhere as this name
> change did not update (filter to) a SQL View that a user needs in order to
> conduct his daily business activities. So, I had to go back and reverse

what
> I did and add that space back in.
>
> I really did not think that changing the name of a field would cause

issues.
> But, like I said, changing the name in this table did not update the View
> that is based on this table and other tables.
>
> How do I change this field name to be without this space and have this
> change update everywhere else effectively in the database including in

this
> View? I tried to change it subsequently in the View but could not figure

out
> how to do so.
>
> Any insights would be appreciated!
>
> Thanks!
>
> childofthe1980s



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com