Questions tagged [convert]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
35 views

Convert sql_variant to varchar to select left 2

Hi I am trying to populate a column (versionstatus) with if the service pack needs updating. I have created a lookup table which lists the SQL Version, and the latest product version, e.g. SQLVersion ...
1
vote
1answer
49 views

Convert Date and Filter by Year

I have a date field that is in a 'yyyymmdd' format, and I need to filter the query by the year, using that field. For example, in my table there is a "Posting Date" field that is in the '20180401' ...
1
vote
0answers
20 views

Unable to change character_set_server on MySQL

I have converted my database to UTF8 but the character_set_server is still Latin1. Is it compulsory to change it to UTF8 or can I just leave it like that? This is a production server, so it's not ...
0
votes
1answer
24 views

combine rows from table with NUM columns

I have this table: Product | Qtdy | Price A | NULL | 123.00 A | 23 | NULL How Can I represent convert like that? Product | Qtdy | Price A | 23 | 123.00 Which ...
0
votes
1answer
69 views

Try_Convert Datetime showing '1/1/1900', want to show space

How do I get try_convert datetime to display NULL when the input is space? I am getting two different results here. My intention is to show 'space' number query as Null also, just like first query. ...
0
votes
1answer
145 views

Fix OGR2OGR “failed when converting the varchar value to data type int” issue in the MSSQL table -

I am a newbie to MSSQL and am trying to convert an MSSQL table to Mapinfo Tab file using OGR2OGR but it keeps failing with the above message on a few tables. I have tried to get a reply in the GIS SE ...
-1
votes
1answer
59 views

Convert SQL Date MMDDYY varchar to Date?

In reading this, https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017 http://www.sqlusa.com/bestpractices/datetimeconversion/ I cannot locate the ...
2
votes
1answer
39 views

Compute Leap Seconds

I use PostgreSQL 11 and have two columns. One is unix timestamp which is not aware of leap seconds and an utc timestamp which is aware of leap seconds. Is there a way either to find the number of ...
0
votes
1answer
80 views

MS SQL -Date and Time Style conversion problem

I need to convert Date and Time Style from USA format to German and than cast that into int data type. So for variable in case below this works fine if I want to display it in Standard 112 (ISO) ...
1
vote
2answers
374 views

Converting Varchar to Int error

I came across an issue today, and while I was able to fix it, I am unsure what caused the issue to happen. I have a column that is Varchar(20). It is used to store just year data (2010, 2011, etc.) ...
3
votes
1answer
3k views

Convert YYYY-MM-DD date (without time zone) to unix timestamp in Postgres

I've got a column of type date with the following value format: YYYY-MM-DD (eg. 2018-08-03). I want to get the unix timestamp equivalent of the dates, but without the timezone. F.e. the date 2018-08-...
3
votes
1answer
3k views

Mysql Pivot rows into dynamic columns with unknown number of columns

I have an output of a query as follows: bid | code | amount | ----------------------------- 2915 | BF | -10700.00 | 2915 | YQ | -300.00 | 2915 | YR | 0.00 | 2915 | YM ...
0
votes
1answer
446 views

Convert MS access to MySQL DB using php

We are creating a system that has a button for converting MS Access DB to MySQL. Is there a way to convert MS Access DB to MySQL using PHP? I would really appreciate any inputs on this one. Thank ...
-1
votes
2answers
106 views

sp_helpdb: how CONVERT created DATETIME

I like sp_helpdb, it gives me the chance to have the big picture. I found a blog that shows how to easily edit it. BTW, I would like to order the results by creation date. In order to do so I have ...
4
votes
1answer
615 views

Collate issues with wrong characters

Well, the problem is well known, but I'm looking for a smarter solution if there's one. For some reason the system doesn't recognize some characters and I can't compare the columns Here is an ...
0
votes
2answers
270 views

Converting from char(26) to datetime2

In course of a change I migrated a database from Oracle 12.1 to MSSQL 2016. Since the two databases handle date differently, I now need to move the fields from char(26) to datetime2. Output format is ...
2
votes
3answers
1k views

SQL - Convert text to a list of numeric values [duplicate]

Looking for SQL code to transform the text string '12,13,14' to this list of numbers +----+ | 12 | +----+ | 13 | +----+ | 14 | +----+ Example: table0.params (varchar) field contains this text: 12,...
0
votes
1answer
8k views

Want to change a timestamp date to an integer YYYYMMDD

I have this input "2017-07-21 15:31:04.853453" and I want it to return "20170721" as output. How can I do it using cast or convert function? My column input is the current time (CURRENT_TIMESTAMP). ...
2
votes
1answer
6k views

CONVERT() returns garbage with CLOBs in Oracle

I am looking to repair a table of data in Oracle, ideally via unprivileged SQL, which has had UTF-8 data inserted into a UTF-8 database, using the Latin-1 character set by mistake. The symbol β GREEK ...
3
votes
2answers
51 views

Transform a number in symbols in a MySql SELECT

I want to know if is possible to transform a numeric return (INT column) in a sequence of symbols direct in a MySQL SELECT. My table is like below: | ID | category | |-----------|----------| |...
1
vote
1answer
4k views

TSQL Convert FLOAT to STRING Truncation/Rounding Issue

SQL Server 2008 R2 Why when converting a FLOAT to a string (Varchar / Nvarchar) using Cast or Convert, does a rounding or truncation occur? Using CAST DECLARE @floatVal FLOAT = 4.76758527755737 ...
3
votes
1answer
700 views

Loading SQL Server from SQLite with image data

I am trying to load a SQL Server database table from a SQLite database. I have been unable to transfer the data between the two databases since there are: Difficulties in accessing the data in the ...
2
votes
4answers
8k views

Format value to configured number of decimal places

I want to format a number to display decimal places according to a configuration value specified in another table. If the configured value is NULL, the number of decimal places should default to 2 (...
4
votes
1answer
6k views

Pages to MB, multiple and divide or just divide?

When you are using things like sys.database_files it gives size of the file, in 8-KB pages, while many other things you are comparing to it to are in MB. There are a number of ways to convert the 8-...
0
votes
1answer
277 views

DateTime Conversion works for string value but for calculated value throws “out-of-range” error

So I keep getting an error and I have no clue what is prompting it. I have the SQL STUFF(STUFF(STUFF(CAST(((ETADate * 10000) + ETATime) * 100 AS NVARCHAR),13,0,':'),11,0,':'),9,0,' ') Which ...
0
votes
1answer
40 views

Creating rows in a table based on columns from another

I have an MS SQL 2012 DB with a table in the following format: account_id site_id IRA RFI XSS SQLi BDP Month 32501 112233 1 4 4 3 0 August,2016 32501 ...
1
vote
2answers
743 views

number of seconds to years-months-weeks-days-HH:MM-SS

I am running this all the time to get HH:MM:SS from a number of seconds: DECLARE @s INT SELECT @s = 23251 SELECT @s , CONVERT(TIME, DATEADD(SECOND, @s, 0)); when I want to add days to the ...
7
votes
3answers
16k views

Inserting date from string: CAST vs CONVERT

Consider the following two ways to convert a datetime varchar string into a date field: SELECT convert(date, '2012-12-21 21:12:00', 20) -- Only date is needed SELECT cast('2012-12-21 21:12:00' as ...
4
votes
2answers
13k views

How to escape XML characters in TSQL before converting to XML?

I have XML structure which is input param for my stored procedure. It contains element with & (which is escaped in XML). When I extract that element to VARCHAR I receive & which is not valid ...
1
vote
1answer
8k views

ERROR: Arithmetic overflow error converting float to data type numeric

I unfortunately have some bad data and need to work around it. I have a Parcel column in a spreadsheet with some parcels that have inadvertently been converted to floating point numbers. I posted a ...