0

I've just been granted access to a SQL Server data warehouse and I'm trying to get to grips with sqlcmd. Coming from a Postgres/psql background, I'm used to being able to quickly look up a table definition using short cuts like \d+ [tablename]. This produces a nice, single screen vertical summary of the table columns, datatypes and constraints. Something like this: \d+ example

The equivalent I've found so far is EXEC sp_help 'table_name' but this prints an unreadable, multi-page mess. Is there a way to clean up this output? Is there a better TSQL command that will give a simple table summary?

1
  • 1
    Consider using SSMS or some other better graphical tool. sqlcmd isn't for the faint-hearted, it's more of an automated tool for batch queries and commands. Jul 31, 2023 at 21:20

1 Answer 1

-1

I don't know the command but you can query the catalog

select COLUMN_NAME, DATA_TYPE, IS_NULLABLE
from INFORMATION_SCHEMA.COLUMNS  
where TABLE_SCHEMA='PUBLIC' and TABLE_NAME='EMP_BIO'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.