Why does select SCOPE_IDENTITY() return a decimal instead of an integer?

Posted by Earlz on Stack Overflow See other posts from Stack Overflow or by Earlz
Published on 2010-04-08T16:20:53Z Indexed on 2010/04/08 16:23 UTC
Read the original article Hit count: 801

So I have a table with an identity column as the primary key, so it is an integer. So, why does SCOPE_IDENTITY() always return a decimal value instead of an int to my C# application? This is really annoying since decimal values will not implicitly convert to integers in C#, which means I now have to rewrite a bunch of stuff and have a lot of helper methods because I use SQL Server and Postgres, which Postgres does return an integer for the equivalent function..

Why does SCOPE_IDENTITY() not just return a plain integer? Are there people out there that commonly use decimal/non-identity values for primary keys?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about scope-identity