How to get all non-nullable column names, types and lengths in a SQL Server database table?
I was working on a SQL Server database table which had around 100 columns and I wanted to insert a new row into that table. But in order to do that I had to know all the non-nullable column names, types and lengths in that table and below is the query I have used to achieve that:
select COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH from information_schema.columns where table_name = 'TABLE_NAME' AND IS_NULLABLE = 'NO'