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 a computed column created with the following line: alter table tbPedidos add
Is it possible to edit computed-column values? I have a computed-col in my table,
I want to create a persisted computed column in a table so that I
I have a column in my sql server 2005 table that should hold the
I have a column in my table called Value1. I then have a computed
I want to have a computed column that is true if the field asofdate
For example, I have a table TableA, with columns Field1, Field2 and Field3. My
I have a table called TableA whch has a foreign key from TableB and
I have a main Table, with several child tables. TableA and TableAChild1 and TableAChild2.
I have a table (table variable in-fact) that holds several thousand (50k approx) rows

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.