sql - How to find the type, length, nullable or not given a table and a field name -


I have a table that has data that maps to fields in other tables in the database. Something like this:

  FieldName is required CUSTNAME 0 PRODQTY 1  

For fields in other tables, the MYFIELD1 and MYFIELD2 maps in the SQL script, I field

So I'm planning to add 2 other varchar fields to the table like this to make it like the type, length (information that we run a sp_help on a table) Looks

  field name is not source source Note: For this source source field, the custom customer's name PRODQTY 1 product quantity  

to map this way, I can get the customer .name In a sql script as varchar .

Which SQL commands can I run that give me the Customer.name field (such as datatype = varchar (200), faucet = not accurate, all about the exact Gives information = 10 etc.) and how do I use this information? For any example, really is appreciated.

My plan is to store table and column names instead of datatip because datatype can be changed in the future and someone should remember to update this table (which can be a maintenance issue )

Besides, I inherited this table from someone else, is there a standard way of doing this?

You want to query INFORMATION_SCHEMA.Column special table, and column Filter by TABLE_NAME and COLUMN_NAME :

  SELECT * to INFORMATION_SCHEMA.Columns where TABLE_NAME = 'table' and 'COLUMN_NAME =' column '< / Code> 

Look at the output and select and choose which columns you will need most are you IS_NULLABLE , DATA_TYPE And NUMERIC_PRECISION .


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -