varchar

Best method for varchar date validation in Sybase (T-SQL)?

I have a stored procedure which takes as its parameter a varchar which needs to be cast as a datetime for later use: SET @the_date = CAST(@date_string AS DATETIME) I'm expecting the date string to be supplied in the format "DD-MON-YYYY", but in an effort to code defensively, if for some reason it can't be cast successfully, I want to ...

varchar vs nvarchar performance

I'm working on a database for a small web app at my school using SQL Server 2005. I see a couple of schools of thought on the issue of varchar vs nvarchar: Use varchar unless you deal with a lot of internationalized data, then use nvarchar. Just use nvarchar for everything. I'm beginning to see the merits of view 2. I know that nva...

Difference between VARCHAR2(11 BYTE) and VARCHAR2(11 CHAR)

In Oracle, what is the difference between : CREATE TABLE CLIENT ( NAME VARCHAR2(11 BYTE), ID_CLIENT NUMBER ) and CREATE TABLE CLIENT ( NAME VARCHAR2(11 CHAR), -- or even VARCHAR2(11) ID_CLIENT NUMBER ) Thank you. ...

What is the difference between nchar(10) and varchar(10) in MSSQL?

What is the difference between nchar and varchar in MSSQL? What does nvarchar mean? Cheers! ...

Size of varchar columns

In sql server does it make a difference if I define a varchar column to be of length 32 or 128? ...

How do you convert VARCHAR to TIMESTAMP in MSSQL?

You'd like to call a stored proc on MS SQL that has a parameter type of TIMESTAMP within T-SQL, not ADO.NET using a VARCHAR value (e.g. '0x0000000002C490C8'). What do you do? UPDATE: This is where you have a "Timestamp" value coming at you but exists only as VARCHAR. (Think OUTPUT variable on another stored proc, but it's fixed alread...

How much more inefficient are text (blobs) than varchar/nvarchar's?

We're doing a lot of large, but straightforward forms for a fairly big project (about 600 users using it throughout the day - that's big for me at least ;-) ). The forms have a lot of question/answer type sections, so it's natural for some people to type a sentence, while others type a novel. How beneficial would it be to put a charact...

Flatten a recordset in SQL Server?

Say you get a recordset like the following: | ID | Foo | Bar | Red | |-----|------|------|------| | 1 | 100 | NULL | NULL | | 1 | NULL | 200 | NULL | | 1 | NULL | NULL | 300 | | 2 | 400 | NULL | NULL | | ... | ... | ... | ... | -- etc. And you want: | ID | Foo | Bar | Red | |-----|-----|-----|-----| | 1 | 100 | ...

Using varchar instead of date field types in MySQL

Is there any reason to use a varchar field instead of a date field in MySQL? I'm looking at an existing site and I see the developer has done this. Is there any reason to? ...

How do I force SqlDataSource to use varchar parameters?

I'm using a SqlDataSource to populate my GridView, because the two seem to be so tightly coupled together. Since this grid shows results of a search, I have a dynamic sql string being written in my codebehind that references parameters I pass in, such as below: sdsResults.SelectParameters.Add("CodeID", TypeCode.String, strCodeID) My p...

Number VS Varchar(2) Primary Keys

I'm now to this point of my project that I need to design my database (Oracle). Usually for the status and countries tables I don’t use a numeric primary key, for example STATUS (max 6) AC --> Active DE --> Deleted COUNTRIES (total 30) UK --> United Kingdom IT --> Italy GR --> Greece These tables are static, not updated through the a...

Equivalent of varchar(max) in MySQL?

What is the equivalent of varchar(max) in MySQL? ...

char vs varchar for performance in stock database

I'm using mySQL to set up a database of stock options. There are about 330,000 rows (each row is 1 option). I'm new to SQL so I'm trying to decide on the field types for things like option symbol (varies from 4 to 5 characters), stock symbol (varies from 1 to 5 characters), company name (varies from 5 to 60 characters). I want to optimi...

How to get trailing spaces from varchar column in Informix using ODBC

I cannot get trailing spaces from varchar column in Informix database. I created test table, filled it with field with some trailing spaces, but they are not returned by SELECT while it seems they are stored in db. CREATE TABLE tmptable (txt varchar(240)); INSERT INTO tmptable (txt) VALUES ('123 '); SELECT txt, txt || '***', LENGTH(t...

Disadvantage of choosing large MAX value for varchar or varbinary

What's the disadvantage of choosing a large value for max when creating a varchar or varbinary column? I'm using MS SQL but I assume this would be relevant to other dbs as well. Thanks ...

Tsql VarChar implicitly to SmallDateTime

When executing the following using a smalldatetime constraint on the returned results, I get zero results: Execute sp_proc @DateOfBirth = '01/01/1900' or Execute sp_proc @DateOfBirth = '1900-01-01' But when using the following varchar argument all the sudden i get results which correspond to 1 Jan 2000. Does smalldatetime imp...

Is there a reason why I shouldn't use NVARCHAR in Sql Server?

I'm designing a database scheme right now and I figure just to be safe I should use nvarchar for my textual column's datatypes (for unicode support). While I don't expect non-english text I figure it would be better to have support it from the begining just in case. Is there any reason why I should stick with plain varchar? Performance...

SQL Server Text type v.s. varchar data type

Hello everyone, I have variable length character data and want to store in SQL Server (2005) database. I want to learn some best practices about how to choose TEXT SQL type or choose VARCHAR SQL type, pros and cons in performance/footprint/function. thanks in advance, George ...

varchar Fields - Is a Power of Two More Efficient?

Is it more efficient to use a varchar field sized as a power of two vs. another number? I'm thinking no, because for SQL Server the default is 50. However, I've heard (but never confirmed) that sizing fields as a power of 2 is more efficient because they equate to even bytes, and computers process in bits & bytes. So, does a field declar...

Removing non-numeric characters in T-SQL

I'm using the function sp_spaceused to get the details of all the tables in a DB. The index_size column is VARCHAR returned complete with ' KB' on the end, however I want to to display in MB. All I need to know is how to strip out the KB, I can do the rest! :D ...