I created a table using SQL Server CE like this:
SqlCeCommand createTableCmd = new SqlCeCommand();
createTableCmd.CommandText = "Create table docEntry (id nvarchar (70) not null PRIMARY KEY, "
+ "parent nvarchar(70), "
+ "lmt bigint not null, "
+ "fileName nvarchar(70) not null)";
Table name is docEntry
, and the column width I need to find out is fileName column.
The purpose is to detect if the column width is 70, if yes, I need to expand it to other size, else leave it.
I tried
SELECT COL_LENGTH(docEntry, fileName)
it caused exception:
SqlCeException was caught:
The column name is not valid. [ Node name (if any) = ,Column name = docEntry ]
I don't know why...
Anyone knows?
Think you will have to do it the long way:
SELECT character_maximum_length
FROM information_schema.columns
WHERE table_name = 'docentry'
AND column_name = 'filename'