Can't set PERSISTED on a computed column??
- From: Paul Sullivan <sullivap@xxxxxxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 20:46:11 -0400
Can't set PERSISTED on a computed column??
// Table structure
CREATE TABLE [dbo].[PatientNodes](
[PrimaryKey] [int] IDENTITY(1,1) NOT NULL,
[PatientNode] [xml] NOT NULL,
CONSTRAINT [PK__PatientNodes__062DE679] PRIMARY KEY CLUSTERED
([PrimaryKey] ASC)
WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
//Typical data in PatientNode column.
<Patient Guid="a3c03bf0-66a5-4561-8dcb-142dbd45bafb">
<Number>777777</Number>
<LegalNames>
<Name StartDate="2006-08-30T13:37:21.1212167-04:00">
<First>Paul</First>
<Last>Dickerson</Last>
</Name>
</LegalNames>
</Patient>
// UDF function
CREATE FUNCTION [dbo].[udf_GuidFromXML] ( @PatientNode xml)
RETURNS uniqueidentifier
AS
BEGIN
DECLARE @Guid uniqueidentifier
SELECT @Guid = @PatientNode.value('/Patient[1]/@Guid',
'uniqueidentifier')
RETURN @Guid
END
/// Adding calculated column
ALTER TABLE PatientNodes
ADD PatientGuid AS [dbo].[udf_GuidFromXML](PatientNode) PERSISTED
This works fine without the PERSISTED keyword, but with it I get this:
"Computed column 'PatientGuid' in table 'PatientNodes' cannot be
persisted because the column is non-deterministic."
I have read the INFo in BOL: "Creating Indexes on Computed Columns",
"Deterministic and Nondeterministic Functions", but can't see my
problem. Getting that guid and returning it looks pretty deterministic
to me. Any suggestions.
Paul V. Sullivan
.
- Follow-Ups:
- Re: Can't set PERSISTED on a computed column??
- From: Bob Beauchemin
- Re: Can't set PERSISTED on a computed column??
- From: Denis Ruckebusch [MSFT]
- Re: Can't set PERSISTED on a computed column??
- From: Kent Tegels
- Re: Can't set PERSISTED on a computed column??
- Prev by Date: Re: Please, please, please Help !!!
- Next by Date: Re: Can't set PERSISTED on a computed column??
- Previous by thread: Re: Please, please, please Help !!!
- Next by thread: Re: Can't set PERSISTED on a computed column??
- Index(es):