Solved

SQL Error Msg 4988 when Creating Table with persisted Computed column

Posted on 2011-03-22
3
666 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 143

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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
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…

732 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