cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

Append JMP Data Table into SQL database with Dates

Hi everyone,

 

I'm trying to upload my data table into SQL & I'm having issues getting the date columns to load in.

The error I receive is this: "[Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: numeric is incompatible with date"

I tried using SELECT CAST to make it into a date format but that didn't work. I'm using JMP 17.0.0.

 

I used the base code from this post & tried to adapt it to what I needed to no avail: https://community.jmp.com/t5/Discussions/How-to-Insert-Append-Write-data-to-SQL-Server-database-in-t...

 

dt = data table ("Untitled 2");

col_list = dt << get column names(string);
col_names = concat items(col_list, ", ");

insert_prefix = evalinsert(
"SELECT CAST(dt:Date as date)";
"SELECT CAST(dt:Accrual_Period_Date as date)";
"INSERT INTO [Sandbox].[dbo].[XXXXXXXX] (^col_names^) VALUES ");

dbc = create database connection("ODBC:Description=;DRIVER=SQL Server;SERVER=XXXXX;UID=XXXX.XXXX;PWD=XXXXX;APP=JMP;WSID=XXXXXX;DATABASE=Sandbox;");
for (i = 1, i <= nrows(dt), i++,
	
	for (k = 1, k <= ncols(dt), k++,
		one_col = col_list[k];
		one_value = column(dt, one_col)[i];
// Surround strings with single quotes
		if (type(one_value) == "String",
			one_value = "'" || one_value || "'";
			,
// Convert numeric to string, handle missing values (.)
			one_value = char(one_value);
			if (one_value == ".", one_value = "NULL");
		);
		if (k == 1,
			sql_string = one_value;
			,
			sql_string = sql_string || ", " || one_value;
		);
	);
	insert_sql = insert_prefix || "(" || sql_string || ")";
	show(insert_sql);

// Do the insert.  Execute SQL does an implicit commit
	execute sql(dbc, insert_sql);
);

close database connection(dbc);

Any help would be appreciated!

1 REPLY 1
mmarchandTSI
Level V

Re: Append JMP Data Table into SQL database with Dates

I send date and datetime values as strings, like '1914-12-20'

Recommended Articles