Posts

Showing posts with the label StackOverflow site

how to describe table in sql server 2008

I n SQL SERVER 2008 : There are two ways to describe :   1)  Here one more solution found with help StackOverflow site I like the answer that attempts to do the translate, however, while using the code it doesn't like columns that are not VARCHAR type such as BIGINT or DATETIME. I needed something similar today so I took the time to modify it more to my liking. It is also now encapsulated in a function which is the closest thing I could find to just typing describe as oracle handles it. I may still be missing a few data types in my case statement but this works for everything I tried it on. It also orders by ordinal position. this could be expanded on to include primary key columns easily as well. Step1: Create Function in Database as CREATE FUNCTION dbo.describe (@TABLENAME varchar(50)) returns table as RETURN ( SELECT TOP 1000 column_name AS [ColumnName],        IS_NULLABLE AS [IsNullable],        DA...