79

Here is my query:

SELECT COUNT(*) FROM Similarities WHERE T1Similarity = 0 OR T2Similarity = 0

Here is the result:

Msg 8115, Level 16, State 2, Line 1

Arithmetic overflow error converting expression to data type int.

The table has 4 billion rows. I don't expect this query to be fast, but after about 5mins, it fails with an overflow error. Is there a COUNT function for bigger data than int?

Thanks.

2 Answers 2

175

Use COUNT_BIG

SELECT COUNT_BIG(*) FROM Similarities WHERE T1Similarity = 0 OR T2Similarity = 0 
Sign up to request clarification or add additional context in comments.

Comments

29
 SELECT COUNT_BIG(*) FROM Similarities WHERE T1Similarity = 0 OR T2Similarity = 0 

1 Comment

I get this answer was posted 1 minute after pstrjds posted theirs, but they're completely identical. Do we need this?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.