if exists(select * from sysobjects where name=N'ColonnesDeTable' and type='IF')
drop function ColonnesDeTable
go
create function ColonnesDeTable(@TableName varchar(50)) returns TABLE
as
RETURN(
select c.colid colid, c.name colname, t.name typename, c.length length, c.xprec prec, c.xscale scale
from syscolumns c
inner join sysobjects o on c.id = o.id
left join systypes t on t.xtype=c.xtype and t.usertype=c.usertype
where o.type in ('S', 'U', 'V', 'IF') and o.name = @TableName)
go
select * from dbo.ColonnesDeTable('sysobjects')