<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Append JMP Data Table into SQL database with Dates in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Append-JMP-Data-Table-into-SQL-database-with-Dates/m-p/679848#M86592</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to upload my data table into SQL &amp;amp; I'm having issues getting the date columns to load in.&lt;BR /&gt;&lt;BR /&gt;The error I receive is this: "[Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: numeric is incompatible with date"&lt;/P&gt;&lt;P&gt;I tried using SELECT CAST to make it into a date format but that didn't work. I'm using JMP 17.0.0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the base code from this post &amp;amp; tried to adapt it to what I needed to no avail:&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/How-to-Insert-Append-Write-data-to-SQL-Server-database-in-table/m-p/262281#M51331" target="_blank"&gt;https://community.jmp.com/t5/Discussions/How-to-Insert-Append-Write-data-to-SQL-Server-database-in-table/m-p/262281#M51331&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = data table ("Untitled 2");

col_list = dt &amp;lt;&amp;lt; 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 &amp;lt;= nrows(dt), i++,
	
	for (k = 1, k &amp;lt;= 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);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;</description>
    <pubDate>Wed, 20 Sep 2023 22:28:12 GMT</pubDate>
    <dc:creator>Bagawandoss96</dc:creator>
    <dc:date>2023-09-20T22:28:12Z</dc:date>
    <item>
      <title>Append JMP Data Table into SQL database with Dates</title>
      <link>https://community.jmp.com/t5/Discussions/Append-JMP-Data-Table-into-SQL-database-with-Dates/m-p/679848#M86592</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to upload my data table into SQL &amp;amp; I'm having issues getting the date columns to load in.&lt;BR /&gt;&lt;BR /&gt;The error I receive is this: "[Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: numeric is incompatible with date"&lt;/P&gt;&lt;P&gt;I tried using SELECT CAST to make it into a date format but that didn't work. I'm using JMP 17.0.0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the base code from this post &amp;amp; tried to adapt it to what I needed to no avail:&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/How-to-Insert-Append-Write-data-to-SQL-Server-database-in-table/m-p/262281#M51331" target="_blank"&gt;https://community.jmp.com/t5/Discussions/How-to-Insert-Append-Write-data-to-SQL-Server-database-in-table/m-p/262281#M51331&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = data table ("Untitled 2");

col_list = dt &amp;lt;&amp;lt; 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 &amp;lt;= nrows(dt), i++,
	
	for (k = 1, k &amp;lt;= 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);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2023 22:28:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Append-JMP-Data-Table-into-SQL-database-with-Dates/m-p/679848#M86592</guid>
      <dc:creator>Bagawandoss96</dc:creator>
      <dc:date>2023-09-20T22:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Append JMP Data Table into SQL database with Dates</title>
      <link>https://community.jmp.com/t5/Discussions/Append-JMP-Data-Table-into-SQL-database-with-Dates/m-p/680018#M86605</link>
      <description>&lt;P&gt;I send date and datetime values as strings, like '1914-12-20'&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 12:00:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Append-JMP-Data-Table-into-SQL-database-with-Dates/m-p/680018#M86605</guid>
      <dc:creator>mmarchandTSI</dc:creator>
      <dc:date>2023-09-21T12:00:52Z</dc:date>
    </item>
  </channel>
</rss>

