Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6155549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:27:16+00:00 2026-05-23T20:27:16+00:00

I have a table TableA with a computed column FieldA bound to a function

  • 0

I have a table TableA with a computed column FieldA bound to a function that returns a float. The function is GetFieldA which calls two sub functions.

I also have a view which includes the GetFieldA function not the computed column value as a field. I just tried to add a index to the view which said it required GetFieldA to be schema bound in order to have a index on it, I changed it to be schema bound (which involved removing the computed column) but then when i went back to try to readd the computed column it said in order to use the GetFieldA the schema bound must be removed.

Is there any way to have a computed column with a schema bound function or do i need to rework how im getting the field in order to be able to have a view index?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:27:17+00:00Added an answer on May 23, 2026 at 8:27 pm

    It’s impossible to add index on a computed column, unless it’s deterministic.

    “Deterministic functions always return the same result any time they are called with a specific set of input values and given the same state of the database. Nondeterministic functions may return different results each time they are called with a specific set of input values even if the database state that they access remains the same.”

    • Creating Indexes on Computed Columns
    • User-Defined Function Design Guidelines

    Example:

    CREATE FUNCTION dbo.FuncA()
    RETURNS [float]
    WITH SCHEMABINDING    -- required option
    BEGIN
      RETURN 1.0   -- DB engine parses body, and marks this func. as 'deterministic'
    END
    GO
    
    CREATE TABLE TableA (
      K int primary key clustered,
      A AS dbo.FuncA() PERSISTED    -- must be persisted
    )
    GO
    
    CREATE VIEW ViewA
    WITH SCHEMABINDING    -- required option
    AS
      SELECT K, A FROM dbo.TableA
    GO
    
    CREATE UNIQUE CLUSTERED INDEX IDX1 ON dbo.ViewA (K, A)
    GO
    

    You have to specify PERSISTED for imprecise data types like [real] and [float], in other case you can freely create an index on a view with computed column ([decimal] will be OK).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have table contain two column id and word . word column may contain
I want to have a computed column that is true if the field asofdate
I have created a sql function in SQLServer 2008 that declared a temporary table
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have a Microsoft Access form that is bound to a linked SQL Server
I have a table that represents the parameters of a contract - including their
I have stored procedure that returns results sorted dynamically. The parent folder (this is
I have a script that appends some rows to a table. One of the
I have something like this create function Answers_Index(@id int, @questionID int) returns int as
I have this table that needs to have (for every row) the average cost

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.