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 5839303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:33:59+00:00 2026-05-22T11:33:59+00:00

CREATE TABLE test2 ( id INTEGER, name VARCHAR(10), family VARCHAR(10), amount INTEGER) CREATE VIEW

  • 0
CREATE TABLE test2 (
id INTEGER,
name VARCHAR(10),
family VARCHAR(10),
amount INTEGER)

CREATE VIEW dbo.test2_v WITH SCHEMABINDING 
AS
SELECT id, SUM(amount) as amount
-- , COUNT_BIG(*) as tmp
FROM dbo.test2 
GROUP BY id

CREATE UNIQUE CLUSTERED INDEX vIdx ON test2_v(id)

I have error with this code:

Cannot create index on view
‘test.dbo.test2_v’ because its select
list does not include a proper use of
COUNT_BIG. Consider adding
COUNT_BIG(*) to select list.

I can create view like this:

CREATE VIEW dbo.test2_v WITH SCHEMABINDING 
    AS
    SELECT id, SUM(amount) as amount, COUNT_BIG(*) as tmp
    FROM dbo.test2 
    GROUP BY id

But I’m just wondering what is purpose of this column in this case?

  • 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-22T11:33:59+00:00Added an answer on May 22, 2026 at 11:33 am

    You need COUNT_BIG in this case because of the fact you are using GROUP BY.

    This is one of many limitations of Indexed Views and because of these restrictions, Indexed Views can’t be used in many places or the usage of it is NOT as effective as it could have been. Unfortunately, it is how it works currently. Sucks, it narrows the scope of usage.

    http://technet.microsoft.com/en-us/library/cc917715.aspx

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

Sidebar

Related Questions

create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int
I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY
I have a table in SQLite: CREATE TABLE test_results(timestamp TEXT, npass INTEGER, nfails INTEGER)
How come the following doesn't work? CREATE FUNCTION Test (@top integer) RETURNS TABLE AS
I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT
like: create table test( score integer unsigned between 1 and 100 ... ); Is
setup: create table main(id integer unsigned); create table test(id integer unsigned,created datetime,text text); insert
setup: mysql> create table main(id integer unsigned); mysql> create table test1(id integer unsigned,body text);
I have the following table: CREATE TABLE TEST(ID TINYINT NULL, COL1 CHAR(1)) INSERT INTO
SQl Server 2005: Option: 1 CREATE TABLE #test (customerid, orderdate, field1 INT, field2 INT,

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.