>Nel Db sql server da dove prendo in input alcune tabelle ho un
>campo dichiarato ntext. Ora, com'è la sintassi per prendere la
>lunghezza massima di questo campo?
Ciao viviana_77,
il data type ntext è in grado di memorizzare fino a 1.073.741.823 caratteri in formato unicode.
Per recuperare la lunghezza in byte della stringa più lunga inserita in una colonna ntext puoi ricorrere alla funzione DATALENGTH():
USE Northwind;
GO
SELECT DATALENGTH([Description]) AS LenDesc
FROM dbo.Categories;
GO
/* Output:
LenDesc
-----------
86
116
70
14
70
28
50
32
(8 row(s) affected)
*/
SELECT MAX(DATALENGTH([Description])) AS MaxLenDesc
FROM dbo.Categories;
GO
/* Output:
MaxLenDesc
-----------
116
(1 row(s) affected)
*/
Per maggiori info leggi il seguente paragrafo sui Books Online:
"DATALENGTH"
http://msdn.microsoft.com/library/en-us/tsqlref/ts_da-db_4ep4.asp
>E poi non esiste un campo blob in sql server? Come si dichiara?
In SQL Server 2000 puoi utilizzare il data type image; in SQL Server 2005 il data type varbinary(max).
>Grazie
Prego.
Ciao!
--
Lorenzo Benaglia
Microsoft MVP - SQL Server
http://blogs.dotnethell.it/lorenzo/
http://italy.mvps.org