header image

Describing the Table in Simple Format – Oracle guys are habituated to get the similer type output through ‘desc’ command

Posted by: | September 19, 2005 | No Comment |

Use Northwind
Go
create procedure des(@tablename varchar(100))
as
select name,(select max(name) from systypes where xtype=sc.xtype) datatype,
length,prec,scale,case isnullable when 1 then ‘Y’ when 0 then ‘N’ else ‘X’ end nullable
from syscolumns sc where id= ( select id from sysobjects where
name=@tablename)
GO
des Products


Output:


















































































name


datatype


length


prec


scale


nullable


ProductID


int


4


10


0


N


ProductName


sysname


80


40


NULL


N


SupplierID


int


4


10


0


Y


CategoryID


int


4


10


0


Y


QuantityPerUnit


sysname


40


20


NULL


Y


UnitPrice


money


8


19


4


Y


UnitsInStock


smallint


2


5


0


Y


UnitsOnOrder


smallint


2


5


0


Y


ReorderLevel


smallint


2


5


0


Y


Discontinued


bit


1


1


0


N



Cheers!!!

under: 9548