常见sql

1.case when else end的使用

/*验证添加字段是否成功,大于0成功,等于0失败*/
USE Lambor_Main
GO
SELECT (case COUNT(1) when 3 then 1 else 0 END) as number FROM sys.tables AS t
INNER JOIN sys.columns AS c ON t.object_id = c.object_id
LEFT JOIN sys.extended_properties AS ep
ON ep.major_id = c.object_id AND ep.minor_id = c.column_id
WHERE
t.name='RakeSetting'
AND
(c.name='CreateMemberID' OR c.name='UpdateDateTime' OR c.name ='CycleReverseAmountLimit')

你可能感兴趣的:(常见sql)