Solved

SQL Error Msg 4988 when Creating Table with persisted Computed column

Posted on 2011-03-22
3
653 Views
Last Modified: 2012-05-11
Hi,
I'm trying to create a table in SQL 2008 that has a Computed column with Presisted property. The Computed formula calls a user defined function in dbo schema. However, table it self resides in a different schema.

When I execute the following (see the code).  I get this error telling me that my table has different owner then the underlaying function.  I even deleted the function and recreated it using the same user login that is creating the table.  How do I fix this.  I Can not put the function into the same schema as the table.  This function must reside in dbo schema because of replication.

Msg 4988, Level 16, State 1, Line 2
Cannot persist computed column 'JoinedName'. Underlying object 'JoinName' has a different owner than table 'Users'.
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

SET ARITHABORT ON
GO

CREATE TABLE [PublicFacing].[Users](
      [UserId] [int] NOT NULL,
      [RegistrantId] [int] NOT NULL,
      [IsPublic] [bit] NOT NULL,
      [Password] [varchar](50) NULL,
      [PasswordMD5] [char](32) NULL,
      [PasswordActivation] [datetime] NULL,
      [ReplicationGUID] [uniqueidentifier] NOT NULL,
      [msrepl_tran_version] [uniqueidentifier] NULL,
      [Status] [smallint] NULL,
      [FirstName] [varchar](80) NULL,
      [MiddleName] [varchar](80) NULL,
      [LastName] [varchar](80) NULL,
      [Suffix] [varchar](80) NULL,
      [Prefix] [varchar](15) NULL,
      [JoinedName]  AS ([dbo].[JoinName]([FirstName],[MiddleName],[LastName],[Suffix])) PERSISTED,
      [AddressLine1] [varchar](60) NULL,
      [AddressLine2] [varchar](60) NULL,
      [USCity] [varchar](60) NULL,
      [USState] [smallint] NULL,
      [USZip5] [int] NULL,
      [USZip4] [smallint] NULL,
      [Country] [smallint] NULL,
      [LastStatusChange] [datetime] NULL,
CONSTRAINT [PK_Users] PRIMARY KEY CLUSTERED 
(
      [UserId] ASC,
      [RegistrantId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [PublicFacing].[Users] ADD  CONSTRAINT [DF_Users_ReplicationGUID]  DEFAULT (newid()) FOR [ReplicationGUID]
GO

ALTER TABLE [PublicFacing].[Users] ADD  CONSTRAINT [MSrepl_tran_version_default_C3AE8422_2E32_4716_8BDE_71A88E4EE9DE_791673868]  DEFAULT (newid()) FOR [msrepl_tran_version]
GO

Open in new window

0
Comment
Question by:vb7guy
3 Comments
 
LVL 8

Assisted Solution

by:Kobe_Lenjou
Kobe_Lenjou earned 250 total points
ID: 35189646
Can you verify if the owers of both schema's are the same (most likely dbo)?
 
select * from sys.schemas

Open in new window


0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 35190578
>Cannot persist computed column 'JoinedName'. Underlying object 'JoinName' has a different owner than table 'Users'.
as the error message reads, the function you want to use has to be in the same owner as the table. either both dbo, or both "users"
0
 

Author Closing Comment

by:vb7guy
ID: 35314246
Both solutions were on the correct path.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now