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))
Los trucos SQL Server 2000 más vistos
Este truco ha recibido 13 votaciones| Nota media: 7Selecciona tu
Puntuación: