The type-conversion tag has no wiki summary.
7
votes
2answers
1k views
Why does “SELECT POWER(10.0, 38.0);” throw an arithmetic overflow error?
I'm updating my IDENTITY overflow check script to account for DECIMAL and NUMERIC IDENTITY columns.
As part of the check I compute the size of the data type's range for every IDENTITY column; I use ...
7
votes
1answer
1k views
Is there such thing as Custom Data Types?
Does MySQL have any support for custom data types? For example, zip codes might be stored in a varchar(10) field, but they could be compacted in to an int, with options for blank, and a flag as to ...
6
votes
1answer
218 views
Warning in query plan “Cardinality Estimate”
create table T(ID int identity primary key)
insert into T default values
insert into T default values
go
select cast(ID as varchar(10)) as ID
from T
where ID = 1
The query above has a warning in ...
4
votes
1answer
207 views
Type safety in WHERE clauses
I've spent the most part of yesterday tracking down a strange bug in our PHP/MySQL application and the culprit seems to be a poor query. We have a table like
...
3
votes
3answers
374 views
Converting CHAR to BIT
I have a column with char(16) data type and it was mistakenly set to char(16) actually it should be bit(1) because it contains only three distinct values as follows:
16 characters long string
10 ...
3
votes
2answers
304 views
Change column data type across database
I have a bunch of tables with many columns of data type ntext. I wish to change all such columns in all tables of a particular database to nvarchar(max), because of planned deprecation (EDIT: also ...
3
votes
1answer
2k views
Oracle: How to create a not null column in a view
Given a table like:
CREATE TABLE "MyTable"
(
"MyColumn" NUMBER NOT NULL
);
I want to create a view like:
CREATE VIEW "MyView" AS
SELECT
CAST("MyColumn" AS BINARY_DOUBLE) AS "MyColumn"
FROM ...
3
votes
1answer
301 views
SQL Server to Oracle Export - Data conversion error
I have a rather weird problem with exporting a bunch of tables from SQL Server 2005 to Oracle database. I have SQL Agent job that deletes Oracle tables, recreates them and then exports the data using ...
2
votes
1answer
275 views
Type conversion with default fallback value
In PostgreSQL (8.4), I'm trying to convert a string parameter into a date within a SQL query, falling back to now() when the string is not a valid date (or empty).
In "pseudo-SQL", this would be ...
1
vote
2answers
61 views
Converting Non Unicode string to Unicode string SSIS
I am creating a package where I will be exporting data from a database into an empty excel file. When I added only the source and destination components and I ran the package I got a conversion error ...
1
vote
2answers
282 views
Convert datetime stored as char the YYYMMDDHHmmSS format to datetime
I'm working with a table where the date and time of an event is stored as a char in the format YYYMMDDHHmmSS or '20120606122012'. I need to compare this to the current timestamp to see if it's been ...
1
vote
1answer
4k views
How can I convert from Double Precision to Bigint with PostgreSQL?
I need to convert a value of Double Precision to Bigint with PostgreSQL. How can I do that?
I have tried with to_bigint(myvalue) but that function didn't exist.
0
votes
2answers
1k views
Convert a datetime column to number of seconds
In my SQL Server database, I have a datetime column. What is a good way to create a new column that represents the long value for the datetime column. The long would represent a number of seconds.
0
votes
1answer
32 views
MySQL Conversion to DATE Type
What is the difference between the return values for these two expressions in MySQL:
date('2011-01-01')
cast('2011-01-01' AS DATE)