Thanks For the Good Question Tom Brown i learnt some thing new today and also i tried to create index on the computed columns it will not alllow to create index directly.
and i tried in this way
PRINT 'Define Table';
CREATE TABLE #Quantities (
ID INT IDENTITY,
DataSource varchar(30) NOT NULL,
QF1 Float,
QF2 Float,
QTot AS QF1 + QF2,
PF1 AS QF1 / (QF1 + QF2),
PF2 AS QF2 / (QF1 + QF2) );
CREATE NONCLUSTERED INDEX IXC1 on #Quantities(ID) INCLUDE(PF1,PF2)
PRINT 'Insert data';
INSERT INTO #Quantities (DataSource, QF1, QF2)
SELECT 'Test 1' , 66, 34;
Print 'Insert Zeroes';
INSERT INTO #Quantities (DataSource, QF1, QF2)
SELECT 'Test 2', 0, 0;
Print 'Insert Nulls';
INSERT INTO #Quantities (DataSource, QF1, QF2)
SELECT 'Test 3', null, null;
PRINT 'Show Table';
SELECT * FROM #Quantities;
DROP TABLE #Quantities
i got the error while inserting the value it self
thanks again for the Good question