2

What is the corresponding C++ data type to the SQL numeric(18,0) data type?

I need a data type in C++ to store numeric(18,0) of SQL in it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Bob
  • 22,810
  • 38
  • 143
  • 225
  • 1
    (18,0) means 18 digits before the decimal point and 0 after. So you can use a `long long` or `int64_t` or `__int64` or whatever is the 64 bit integer on your system. – Mr Lister May 02 '12 at 07:01
  • my problem is _variant_t that reads data from sql does not support LONGLONG – Bob May 02 '12 at 07:07
  • You are using MSVC, right? What version? AFAIK variant_t does support 64 bits ints. Oh, and what kind of database are you reading from? SQL Server? – Mr Lister May 02 '12 at 07:10
  • Oh, I just read your other question, where you say this is for the WinCE platform, and _variant_t doesn't contain __int64 there. I didn't know, and I have no idea how to solve that, sorry. – Mr Lister May 02 '12 at 07:28

2 Answers2

4

It says on MSDN that the numeric is mapped to CString in C++.

Reference: SQL: SQL and C++ Data Types (ODBC)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
phantasmagoria
  • 319
  • 1
  • 5
1

That would be a long long (at least 64 bits).

wallyk
  • 56,922
  • 16
  • 83
  • 148