Solved

SQL Error Msg 4988 when Creating Table with persisted Computed column

Posted on 2011-03-22
3
644 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
Comment Utility
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
Comment Utility
>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
Comment Utility
Both solutions were on the correct path.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

772 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

14 Experts available now in Live!

Get 1:1 Help Now