0

I'm currently working on pulling some data from a SQL Server database into ServiceNow via JDBC. The problem I'm having is that the query is bringing back null values for some of the columns.

The query I'm running from SNOW is

select [Capacity (Bytes)] 
from memory_table 

which returns null values for the column Capacity (Bytes). In the SQL Server database, the table was created with the column name as Capacity (Bytes) with the space and parenthesis in it and I think that's why its coming back null.

I've tried adding the brackets, double quotes, and single quotes around the name of the column in the query but the result is the same. If I try the query with another column in the table which is formatted correctly it works just fine.

Any help would be appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
vinit
  • 1

1 Answers1

1

I suspect that you are running into an issue where you are querying the display name rather than the column name, test your query through the ServiceNow ODBC driver and tools to debug. http://wiki.servicenow.com/index.php?title=Using_Interactive_SQL_With_ODBC

I suspect that your query will return an error since that is probably a display name. For example, if you query [Assignment group] instead of assignment_group, you'll get an error.

select number, short_description, [Assignment group] from incident where number = 'INC0012345';

Result

The following error information describes the failure
ODBC Call     = SQLPrepareW()
SQL State     = 42S22
Native error  = 10125(278D)
Error Message = [SN][ODBC ServiceNow driver][OpenAccess SDK SQL Engine]Column:Assignment group not found.

Switching to the column name will work

select number, short_description, assignment_group from incident where number = 'INC0012345';

Result

NUMBER  short_description       assignment_group

INC0012345      My incident short descrtiption     123b1c123f12f1234567e123b1234abc
Kirk
  • 16,182
  • 20
  • 80
  • 112
  • My first reaction, too. And +1 because this is generally good advice for someone trying to pull info OUT of ServiceNow, but it seems like this person's problem is pulling info IN to Servicenow from their own SQL Server db. – Joey Mar 28 '16 at 20:58