Enlaces patrocinados:

Trucos de Sql Server Columnas Text en SQL Server

Las columnas de Texto del SQL Server se tienen que tratar de una forma especial debudo a su tamaño.
Algunas de las funciones que trabajan con VARCHAR no son legales con el campo tipo Text.
Para tratar campos tipo text:

-- getting the number of characters

SELECT LEN(data)
-- becomes
SELECT DATALENGTH(data)

-- getting the first 5 characters

SELECT LEFT(data,5)
-- becomes
SELECT SUBSTRING(data,1,5)

-- getting the last 5 characters

SELECT RIGHT(data,5)
-- becomes
SELECT SUBSTRING(data,DATALENGTH(data)-4,5)

-- changing case

SELECT LOWER(data)
SELECT UPPER(data)
-- becomes
SELECT LOWER(SUBSTRING(data,1,DATALENGTH(data))
SELECT UPPER(SUBSTRING(data,1,DATALENGTH(data))

Comentarios sobre Columnas Text en SQL Server


Lola dice:

That's a mold-breaker. Great thnkinig!
Comentario publicado 17/05/2011 13:54:00
Dejar un comentario

Nombre:

Mail:

Web:

Comentario:

Código de seguridad

Captcha

Inserta el código de seguridad