码迷,mamicode.com
首页 > 其他好文 > 详细

表封装与初始化语句

时间:2017-03-15 20:36:56      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:ase   unique   end   bit   class   pre   nts   set   integer   

SELECT ‘private ‘+A.MyDataType+‘ ‘+A.COLUMNNAME+‘;‘ FROM (
	Select A.name COLUMNNAME,
	B.name,
	CASE WHEN CHARINDEX(‘bigint‘,B.name)>0 then ‘Long‘
	  WHEN CHARINDEX(‘int‘,B.name)>0 then ‘Integer‘
	  WHEN CHARINDEX(‘float‘,B.name)>0 then ‘Double‘
	   WHEN CHARINDEX(‘decimal‘,B.name)>0 then ‘BigDecimal‘
	  WHEN CHARINDEX(‘char‘,B.name)>0 then ‘String‘
	  WHEN CHARINDEX(‘datetime‘,B.name)>0 then ‘Date‘
	  WHEN CHARINDEX(‘bit‘,B.name)>0 then ‘Boolean‘
	  WHEN CHARINDEX(‘money‘,B.name)>0 then ‘BigDecimal‘
	else ‘‘ end MyDataType from syscolumns  A
	LEFT JOIN systypes B
	ON A.xtype=B.xusertype
	Where A.ID=OBJECT_ID(‘CurrentStock‘) 
	--and a.name =‘strContractGUID‘
	and a.name not like ‘%ufts%‘ and a.name not like ‘%uniqueidentifier%‘
) A
 
 SELECT ‘_Stock.set‘+A.COLUMNNAME+‘(‘+
	 case when MyDataType=‘Long‘ then ‘0‘ 
	 when MyDataType=‘Integer‘ then ‘0‘ 
	 when MyDataType=‘Double‘ then ‘0.0‘ 
	 when MyDataType=‘BigDecimal‘ then ‘BigDecimal.ZERO‘ 
	 when MyDataType=‘String‘ then ‘String‘ 
	 when MyDataType=‘Date‘ then ‘new Date()‘ 
	 when MyDataType=‘Boolean‘ then ‘0‘ 
	 else ‘‘ end  +‘)‘ 
 FROM (
	Select A.name COLUMNNAME,
	B.name,
	CASE WHEN CHARINDEX(‘bigint‘,B.name)>0 then ‘Long‘
	  WHEN CHARINDEX(‘int‘,B.name)>0 then ‘Integer‘
	  WHEN CHARINDEX(‘float‘,B.name)>0 then ‘Double‘
	   WHEN CHARINDEX(‘decimal‘,B.name)>0 then ‘BigDecimal‘
	  WHEN CHARINDEX(‘char‘,B.name)>0 then ‘String‘
	  WHEN CHARINDEX(‘datetime‘,B.name)>0 then ‘Date‘
	  WHEN CHARINDEX(‘bit‘,B.name)>0 then ‘Boolean‘
	  WHEN CHARINDEX(‘money‘,B.name)>0 then ‘BigDecimal‘
	else ‘‘ end MyDataType from syscolumns  A
	LEFT JOIN systypes B
	ON A.xtype=B.xusertype
	Where A.ID=OBJECT_ID(‘CurrentStock‘) 
	--and a.name =‘strContractGUID‘
	and a.name not like ‘%ufts%‘ and a.name not like ‘%uniqueidentifier%‘
) A

  

表封装与初始化语句

标签:ase   unique   end   bit   class   pre   nts   set   integer   

原文地址:http://www.cnblogs.com/fastsnail/p/6556089.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!