Using SQL statment query the fileds data type for table name

use AX2009DEV
go

--lowercase to display the column name
select 'EXEC sp_rename '''+sysobjects.name + '.' + syscolumns.name + ''',' + '''' + lower(syscolumns.name) + ''''
from sysobjects join syscolumns on sysobjects.id = syscolumns.id
where sysobjects.name = 'CustTable' -- specify table name such as custTable
go
 



--batch query the field's data type for this table
select dbo.sysobjects.name as 'Table_name', dbo.syscolumns.name as 'Column_name',dbo.systypes.name
From dbo.syscolumns
inner join dbo.sysobjects on dbo.syscolumns.id = dbo.sysobjects.id
left join dbo.systypes on dbo.syscolumns.xusertype = systypes.xusertype
where dbo.sysobjects.name = 'salesTable' and (dbo.sysobjects.xtype = 'u')
and (NOT (dbo.sysobjects.name LIKE 'dtproperties'))
and systypes.name = 'numeric' --specify data type
go
原文地址:https://www.cnblogs.com/Fandyx/p/2055126.html