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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 can not modify function

Author  Topic 

ssunny
Posting Yak Master

133 Posts

Posted - 2009-01-14 : 13:16:51
Hello Guys,

I have a table like this:

create table dbo.test
(
test_id int not null,
a varchar (50),
b varchar (50),
c as dbo.fn_calculate (e),
d varchar (50),
e varchar (50)
)

As you can see c is the derived field which uses function call dbo.fn_calculate (e).
Now for some reason I need to modify dbo.fn_calculate function but i got this error.

Cannot ALTER 'dbo.fn_calculate ' because it is being referenced by object 'test'
How can I fix this this?

Thanks for the help.

ssunny
Posting Yak Master

133 Posts

Posted - 2009-01-14 : 14:43:02
Nevermind fixed the problem. This is what I did:

alter table test
add c_temp varchar (50)
go

update test
set c_temp = c
go

alter table test
drop column c
go

alter function dbo.fn_calculate
...............

go

alter table test
add c as dbo.fn_calculate (e)
go

alter table test
drop column c_temp
go

I don't know if this was the best approach or not!!

Thanks.
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-01-14 : 15:09:44
you did the right thing.
Go to Top of Page
   

- Advertisement -