asp.net - find variable length for sql server datatype nvarchar from c# code -


can find allowed variable length nvarchar type in sql server 2008 c# code in asp.net application?

for eg:

nvarchar(?)

i want find maximum allowed number "?" c# code.

you can use t-sql query @ system catalog views:

select      [max_length] sys.columns  [object_id] = object_id('yourtablenamehere') , name = 'yourcolumnnamehere' 

this return stored, defined maximum length (in characters) column

update: if want find out max length of type (not column of of tables), can use query instead:

select      name, max_length sys.types  name in ('varchar', 'nvarchar') 

be aware: returns max length in bytes (not in characters!) 8000 both types. varchar, 8000 bytes equal 8000 characters, while nvarchar, 8000 bytes corresponds 4000 characters.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -