Tuesday, February 14, 2012

Constraints on Table Field

Hi,

I have a table which saves attachment files.

I need to create a constraint on table which will restrict the size of attachments in the table. How this can be done? I know we can create a check constraint on table but how to restrict the field size? Pls. advise. Thanks in advance.

Are you storing your files as text in the table? If so you might be able to do something checking the datalength like:

create table dbo.testor
( targetFile nvarchar(max)
check ( datalength(targetFile) <= 30000 )
)

|||

Thanks for your response.

I am using image as datatype to attach files. I need to restrict this column size to only accept 50 kb size.

Thanks,

No comments:

Post a Comment