if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[getcoltype]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[getcoltype]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE PROCEDURE getcoltype
@tablename varchar(50)
AS
declare @objid int,@objname char(40)
set @objname =@tablename
select @objid = id from sysobjects where id = object_id(@objname)
select 'Column_name' = tsc.name, 'Colume_type' = tst.name + '(' + convert(varchar(4),tst.length) + ')'
from syscolumns tsc, systypes tst
where id = @objid AND tsc.xtype = tst.xtype
order by colid
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO