34,588
社区成员
发帖
与我相关
我的任务
分享
select convert(varchar(20),name)name,xtype,length from syscolumns where id=OBJECT_ID('MortgageMachinery')
/*
name xtype length
-------------------- ----- ------
AutoID 56 4
MortgageMachineryID 167 50
Mortgager 167 50
MortgagerNumber 167 50
Address 167 50
MortgageName 167 50
Type 167 50
Amount 56 4
Unit 167 50
InvoiceMoney 106 9
MortgageMoney 106 9
MortgageLimitTime 56 4
EvaluateMoney 106 9
MortgageRate 106 9
InvoiceNo 167 50
InvoiceDate 61 8
Manufacturer 231 60
DeviceBrand 231 60
SumPrice 231 60
Remark 231 600
custID 167 20
Valuation 106 9
(22 行受影响)
*/
select (case when sc.xtype<>231 then sc.length else sc.length/2 end )as maxLength
from syscolumns as sc where sc.id=object_id('MortgageMachinery') and sc.name='Manufacturer'
/*
maxLength
-----------
30
(1 行受影响)
*/
go
declare @maxLength int
select @maxLength =(
case when sc.xtype=231 then ISNULL(sc.length/4,0)
else ISNULL(sc.length,0) end )
from syscolumns as sc where sc.id=object_id('MortgageMachinery') and sc.name='Manufacturer'
print @maxLength
declare @maxLength int
select @maxLength =(
case when NOT (sc.xtype=231)
then ISNULL(sc.length,0)
else ISNULL(sc.length/2,0) end )
from syscolumns as sc where sc.id=object_id('MortgageMachinery') and sc.name='Manufacturer'
print @maxLength