I found the answer in a post on Stack Overflow in English, follow the answer code:
SELECT
c.name 'Column Name',
t.Name 'Data type',
c.max_length 'Max Length',
c.precision ,
c.scale ,
c.is_nullable,
ISNULL(i.is_primary_key, 0) 'Primary Key'
FROM
sys.columns c
INNER JOIN
sys.types t ON c.user_type_id = t.user_type_id
LEFT OUTER JOIN
sys.index_columns ic ON ic.object_id = c.object_id AND ic.column_id = c.column_id
LEFT OUTER JOIN
sys.indexes i ON ic.object_id = i.object_id AND ic.index_id = i.index_id
WHERE
c.object_id = OBJECT_ID('YourTableName')
Just replace 'YourTableName'
with the table name you want to analyze.
Works from SQL-Server 2005 up!
The link to the original post is:
Answer - In English
About "how many characters he is able to support", depends on how it was declared. You are using Management Studio to build the query?
– José Diz
I didn’t quite understand the part about "how many characters he is able to support", you refer to the amount of characters that the column will store sent in the
value
at the time ofinsert
?– RXSD
Yes, I’m using Management Studio.
– Leonardo Oliveira
I meant the size of the field itself, @Andréfilipe .
– Leonardo Oliveira
Ah, I understood Leonardo. In this case it depends on how much the attribute
LENGTH
return, the number of characters cannot exceed this value.– RXSD