I could not help but noticed that you modified the timestamp, versus generated by Squirrel, ever so slightly: yours only contains 3 digits for milliseconds.
Converting your statement to an MWE, I can get it to work, but if I add back 3 extra digits for milliseconds, as Squirrel generates, I get an error again. Run this:
declare @APR2010 table ([hire date] datetime)
SELECT *
FROM @APR2010 WHERE [HIRE DATE] > {ts '2010-03-31 00:00:00.000'} -- yours
SELECT *
FROM @APR2010 WHERE [HIRE DATE] > {ts '2010-03-31 00:00:00.000000'} -- Squirrel's
There needs to be a setting for output format of timestamps, as not everyone wants the ODBC TS format, and even searching/replacing in the generated scripts is a tedious task. I assume some code is already roughed in where my screen shot was showing, it only needs to be enhanced to apply to generated outputs.
Thank you!
Alex
-----Original Message-----
From: Alexandre Peshansky [mailto:Ale...@ei...]
Sent: Wednesday, June 28, 2017 4:44 PM
To: Alex Malmyguine
Cc: squ...@li...
Subject: RE: [Squirrel-sql-users] Date/time format in the generated insert into script for SQL Server
SELECT *
FROM [Dental].[dbo].[APR2010] WHERE [HIRE DATE] > {ts '2010-03-31 00:00:00.000'}
--
Alexandre Peshansky, MS
Lead Bioinformatics Analyst, Research Informatics Core (RIC) Harold & Muriel Block Institute for Clinical & Translational Research at Einstein and Montefiore Albert Einstein College of Medicine
1300 Morris Park Ave, Block Bldg., Rm 534 Bronx, NY 10461
(718) 430-2440, (914) 457-6792 (office) (201) 970-3530 (cell) - NEW!!!
-----Original Message-----
From: Alex Malmyguine [mailto:ale...@bl...]
Sent: Wednesday, June 28, 2017 4:05 PM
To: squ...@li...
Subject: Re: [Squirrel-sql-users] Date/time format in the generated insert into script for SQL Server
Can you provide an example of a working SQL statement with that as a datetime value, executable in SQL server?
Thank you
Alex
-----Original Message-----
From: Alexandre Peshansky [mailto:Ale...@ei...]
Sent: Wednesday, June 28, 2017 3:50 PM
To: Alex Malmyguine
Cc: squ...@li...
Subject: RE: [Squirrel-sql-users] Date/time format in the generated insert into script for SQL Server
Is this a more reliable source: https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/date-time-and-timestamp-escape-sequences ?
It specifies the same {ts 'yyyy-mm-dd hh:mi:ss.sssss'} as Gerd quoted from Oracle.
--
Alexandre Peshansky, MS
Lead Bioinformatics Analyst, Research Informatics Core (RIC) Harold & Muriel Block Institute for Clinical & Translational Research at Einstein and Montefiore Albert Einstein College of Medicine
1300 Morris Park Ave, Block Bldg., Rm 534 Bronx, NY 10461
(718) 430-2440, (914) 457-6792 (office) (201) 970-3530 (cell) - NEW!!!
-----Original Message-----
From: Alex Malmyguine [mailto:ale...@bl...]
Sent: Wednesday, June 28, 2017 2:48 PM
To: Gerd Wagner; squ...@li...
Subject: Re: [Squirrel-sql-users] Date/time format in the generated insert into script for SQL Server
Greg,
Why should I look at Oracle docs for MS SQL? Not sure I understand. Obviously, executing this will result in an error in MS SQL:
select {ts '2017-02-24 10:56:12.790000'}
Msg 241, Level 16, State 3, Line 1
Conversion failed when converting date and/or time from character string.
However this works:
select '2017-02-24 10:56:12.790'
There may be some valid considerations for using the former format, but the statements are generated from MS SQL database, therefore should run in MS SQL correctly whether in Squirrel or any other client. This is not happening - the former format only runs in Squirrel. If I generated a statement in Squirrel, I therefore cannot provide it to another person not using Squirrel, and I cannot save it to source control as no one will be able to apply it. The setting I mentioned should apply to generated timestamps as well.
Makes sense?
Thank you
Alex
-----Original Message-----
From: Gerd Wagner [mailto:ger...@t-...]
Sent: Monday, June 26, 2017 4:30 PM
To: Alex Malmyguine; squ...@li...
Subject: Re: [Squirrel-sql-users] Date/time format in the generated insert into script for SQL Server
Am 20.06.2017 um 17:08 schrieb Alex Malmyguine:
> When generating an INSERT-INTO script from the result of a select
> statement, the DATETIME column values come across as follows:
>
> {ts '2017-02-24 10:56:12.790000'}
>
> The correct format would be as follows:
>
> '2017-02-24 10:56:12.790'
No, it isn't. The upper form is correct. See section 13.4.2 of the JDBC specification here:
http://download.oracle.com/otndocs/jcp/jdbc-4_2-mrel2-eval-spec/index.html
>
> Also, BIT fields come across as 'true' or 'false' which confuses SQL
> Server when this executes. Can those be changed to 1/0?
This should be possible by the help of the MSSQL Plugin. Do you use the plugin. If not please try it out and see if it already works. If not you might want to file a feature request here:
https://sourceforge.net/p/squirrel-sql/feature-requests/?source=navbar
Gerd
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Squirrel-sql-users mailing list
Squ...@li...
https://lists.sourceforge.net/lists/listinfo/squirrel-sql-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Squirrel-sql-users mailing list
Squ...@li...
https://lists.sourceforge.net/lists/listinfo/squirrel-sql-users
|