all groups > sql server msde > may 2005 >
You're in the

sql server msde

group:

Question on Formula


Question on Formula Deck
5/23/2005 12:00:00 AM
sql server msde:
I have a computed field that I want to change the
formula. How do I do this in SQL ?

thanks in advance

Re: Question on Formula Deck
5/24/2005 12:00:00 AM

[quoted text, click to view]

thanks, i was also thinking of the same way. but dropping and re-creating
the field will place the field on the last position. is there anyway to
maintain
its position to where it was?

Re: Question on Formula Andrea Montanari
5/24/2005 12:00:00 AM
hi,
[quoted text, click to view]

in a relational database the column position is insignificant... and should
be the same for client applications as you should not use SELECT * but a
well defined select list... anyway, you can achieve the desired result
creating a temporary table with all the columns in the desired order,
migrate data to the new table, drop the old one and renaming the new one...
and of course re-setting all idxs, fks, triggers, constraints, extended
properties...
--
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtm http://italy.mvps.org
DbaMgr2k ver 0.12.0 - DbaMgr ver 0.58.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
--------- remove DMO to reply

Re: Question on Formula Jacco Schalkwijk
5/24/2005 10:37:22 AM
You have to drop and recreate the computed column to change the formula:

CREATE TABLE a (b INT, c AS b*b)
GO
ALTER TABLE a DROP COLUMN c
GO
ALTER TABLE a ADD c AS b*2

--
Jacco Schalkwijk
SQL Server MVP


[quoted text, click to view]

AddThis Social Bookmark Button