varchar

Converting this varchar to a decimal with the appropriate decimal point?

Hi everyone, I've been playing with cast()s and such with this and can't seem to get things to work. I have a varchar string that's 18 characters long that I'd like to convert or cast to a decimal, with five decimal places. So for instance, this string: 00000001987600130 Would become 19876.00130 It's the case that I'll always have ...

PDO PHP query against Teradata using ODBC connect string returns no data from 5th column onwards

I'm using PDO to extract data from Teradata, using an ODBC connect string. The query returns the correct number of rows but column 5 onwards is blank (as compared to using the same query with the PHP ODBC library) Column 5 happens to be a varchar(400) field and I've read that PDO had bugs in the past with varchar columns > 255 in lengt...

NULL Characters in Firebird VARCHAR

Hello there, Im trying to find records in a VARCHAR column that may contain a NUL (0x00), and I cannot find a way to locate the NUL character. Any ideas are welcome. -Israel ...

How rigid is the max size of a VARCHAR in SQL Server?

i.e. if I create a VARCHAR(50) field, what happens if I try to assign it a value that's 100 characters long? Will SQL Server let me do this? Is it somehow less efficient? ...

Postgres: Reduce varchar size and truncate

I currently have a Postgres 8.4 database that contains a varchar(10000) column. I'd like to change this into a varchar(255) and truncate any data that happens to be too long. How can I do this? ...

find elements of a varchar in another varchar

hi, i have a varchar field with the content like these: a,b,c,d e,d,a,c b,q,d,e i need to do a query that select only the rows with the field that has elements equals with an input string. ex input: c,a rows selected: a,b,c,d e,d,a,c is possible without use the OR (field like '%a%' OR field like '%c%') ? thanks ...

My VARCHAR(MAX) field is capping itself at 4000; what gives?

Hello all... I have a table in one of my databases which is a queue of emails. Emails to certain addresses get accumulated into one email, which is done by a sproc. In the sproc, I have a table variable which I use to build the accumulated bodies of the emails, and then loop through to send each email. In my table var I have my body colu...

Are there disadvantages to using VARCHAR(MAX) in a table?

Here is my predicament. Basically, I need a column in a table to hold up an unknown length of characters. But I was curious if in Sql Server performance problems could arise using a VARCHAR(MAX) or NVARCHAR(MAX) in a column, such as: 'This time' I only need to store 3 characters and most of the time I only need to store 10 characters. B...

SQL Better performance: char(10) and trim or varchar(10)

I have a database that uses codes. Each code can be anywhere from two characters to ten characters long. In MS SQL Server, is it better for performance to use char(10) for these codes and RTRIM them as they come in, or should I use varchar(10) and not have to worry about trimming the extra whitespace? I need to get rid of the whitespace...

django select max field from mysql when column is varchar

Hi, Using Django 1.1, I am trying to select the maximum value from a varchar column (in MySQL.) The data stored in the column looks like: 9001 9002 9017 9624 10104 11823 (In reality, the numbers are much bigger than this.) This worked until the numbers incremented above 10000: Feedback.objects.filter(est__pk=est_id).aggregate(sid...

Varchar(255) to Varchar(MAX)

Is it possible to change a column type in a SQL Server 2008 database from varchar(255) to varchar(MAX) without having to drop the table and recreate? SQL Server Management Studio throws me an error every time I try to do it using that - but to save myself a headache would be nice to know if I can change the type without having to DROP a...

From varchar(36) to UNIQUEIDENTIFIER

I am trying to cast an AuctionId that is a UNIQUEIDENTIFIER to an varchar(36) and then back to an UNIQUEIDENTIFIER. Please help me. CAST((SUBSTRING(CAST([AuctionId] as VARCHAR(36)), 0, 35) + '1') AS UNIQUEIDENTIFIER) But I keep getting this error: Msg 8169, Level 16, State 2, Line 647 Conversion failed when converting from a c...

SQL Server, varchar data to nvarchar data

I've got a database with collation Danish_Norwegian_CS_AS and lots of varchar columns. I'd like to convert all this data to unicode, but haven't found a way to convert this data yet. If I've understood correctly, the encoding used is UCS-2 little endian. For example I've got a column containing 'PÃ¥l-Trygve' which is easily converted w...

MySQL VARCHAR strange column behavior

I have the following SQL statement which returns a single record as expected: select * from geodatasource_cities C, geodatasource_countries D where C.CC_FIPS = D.CC_FIPS and D.CC_ISO='AU' and UCASE(TRIM(C.FULL_NAME_ND)) LIKE '%JAN JUE%'; However, If I use the following SQL statement, no records are returned. I ha...

Postgres: Convert varchar to text

I screwed up and created a column as a varchar(255) where that is no longer sufficient. I've read that varchar has no performance benefits over text on Postgres, and so would like to convert the varchar to a text column in a safe way that preserves the data. What's the best way for me to do this? ...

How to trim all columns in all rows in all tables of type string?

Hi folks, In Oracle 10g, is there a way to do the following in PL/SQL? for each table in database for each row in table for each column in row if column is of type 'varchar2' column = trim(column) Thanks! ...

VARCHAR does not work as expected in Apache Derby

I'm having this same problem: How can I truncate a VARCHAR to the table field length AUTOMATICALLY in Derby using SQL? To be specific: CREATE TABLE A ( B VARCHAR(2) ); INSERT INTO A B VALUES ('1234'); would throw a SQLException: A truncation error was encountered trying to shrink VARCHAR '123' to length 2. ...

How can I trim certain characters from a string in sql?

I would like to trim all special characters from a string in SQL. I've seen a bunch of people who use substring methods to remove a certain amount of characters, but in this case the length on each side of the string is unknown. Anyone know how to do this? Thanks, Matt ...

varchar comparison in SQL Server

I am looking for some SQL varchar comparison function like C# string.compare (we can ignore case for now, should return zero when the character expression are same and a non zero expression when they are different) Basically I have some alphanumeric column in one table which needs to be verified in another table. I cannot do select A...

Check if concatenating to a varchar(max) will go beyond max allowable characters

I am trying to concatenate a list of IDs into a varchar(max) to pass into an openquery for a bulk update of data. My question is, is there an easy way to see if a string is beyond the length a varchar(max) can handle aside from comparing it to the number? I have seen this: http://stackoverflow.com/questions/1761124/how-many-characters-...