Converts an expression of one data type to another.

learn more… | top users | synonyms

0
votes
0answers
24 views

How to enable implicit casts in PostgreSQL >=9.2?

Coming from this topic on SO a user suggest me to enable implicit casts in my PostgreSQL and I don't know how to do that. I also don't know if this is a good practice or if it's the solution to the ...
0
votes
1answer
39 views

What does SELECT ~0; do?

I've recently stumbled into an interesting Mysql query: SELECT ~0; results: 18446744073709551615 Which is the max value of a bigint unsigned. What does the tilde operator do in this case?
0
votes
0answers
23 views

How to CAST a value in PostgreSQL for use in WHERE with LIKE statement? [migrated]

I'm trying to fix a SQL query for later convert it to Doctrine2 DQL since it's part of a Symfony2 project. This is what my DDL has: CREATE TABLE "nomencladores"."norma" ( "id" int4 NOT NULL, ...
0
votes
1answer
38 views

I need to insert data from one table to another after casting the values

i have #temp table containing all details to insert into table(named:Customer) The column names of two tables are exactly equal,but datatypes are different.So i need to cast it before insert into ...
3
votes
2answers
399 views

PostgreSQL using count() to determine percentages (cast issues)

I'm trying to run the following query to provide the % of records in my patients table that have a value entered in the refinst field. I keep getting a result of 0. select (count (refinst) / (select ...
4
votes
1answer
418 views

How do I decompose ctid into page and row numbers?

Each row in a table has a system column ctid of type tid that represents the physical location of the row: begin; create table t(id serial); insert into t default values; insert into t default ...
0
votes
2answers
88 views

Does CAST(DateTime AS DATE) cause the entire table to be CAST before comparison? [duplicate]

This is a very common need in the WHERE clause of our SQL statements: CAST(Something.CreationDate AS DATE) BETWEEN CAST(@firstDate AS DATE) AND CAST(@lastDate AS DATE) All of the fields are of ...
1
vote
1answer
119 views

Error updating zoned field from SQL Server stored procedure linked server to iSeries

I'm trying to update a table on an iSeries (AS400) within a SQL Server stored procedure using linked server, but it is failing when trying to update a column defined as zoned. In my stored ...
1
vote
4answers
265 views

Casting fails on subquery result [duplicate]

I'm in a bit of a pickle, I have to perform a query on a database with rather poor data quality. I am trying to evaluate a field which contains a date, but which was defined as a nvarchar. I thought I ...
0
votes
3answers
664 views

SQL Server: CONVERT From ISO8601 To DateTime Within Query

I have a Microsoft SQL Server 2008 R2 database where the DateTime column is not a datetime data type, but varchar(50). Our website logs that data and I don't really have control over it (I'm sure a ...
3
votes
1answer
440 views

Why does implicit conversion from sql_variant (basetype decimal) not work well with float

Why is ResultFloat = 0 in the query below? Am I missing a point within the cast/convert, sql_variant docs? declare @v sql_variant = convert(decimal(28,8), 20.0); select ...
3
votes
1answer
886 views

How to create an index on an integer json property in postgres

I can't figure out for the life of me how to create an index on a property of my json column which is an integer. I tried it this way (and also dozens of others) CREATE INDEX user_reputation_idx ON ...
1
vote
2answers
585 views

Remove scientific notation from an XML column

I have a XML column as shown below: <Root> <Row> <Rowid>1</Rowid> <date>2013-05-06</date> <Balance>1.0002E7</Balance> </Row> ...
2
votes
1answer
879 views

In Postgres, how do I cast character varying to an enum type?

I have a Postgres 8.4 table with columns that are of type "character varying", but I want to convert them to an enum type. When trying to alter the table ALTER TABLE logs ALTER COLUMN interface_type ...
1
vote
1answer
1k views

Converting ZIP code string to integer in SQL Server

I have a SQL Server table pairing zipcodes and lat/long geometry, such as below ID ZIP5 geom 1 356HH 0xE610000001044E00....FFFFFFFF0000000003ID 2 35677 0xE6100000010404000000068....000003 ...
3
votes
2answers
4k views

changing float->numeric casts from assignment to implicit, dangerous?

In porting an application to PostgreSQL (9.1), one odd SQL incompatibility I've discovered concerns the round() function, specifically the version that takes a second argument indicating the rounding ...