十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
select * from xxxx where datediff(m,dt1,dt2)
创新互联建站是专业的亭湖网站建设公司,亭湖接单;提供做网站、成都网站设计,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行亭湖网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
datediff:日期比较函数,SQL server自带的,会将比较的两个日期比较部分的差值返回,m表示比较月
SET @COUNTA= len(replace(@ROW,',',',,'))-len(@ROW)
SET @COUNTB=LEN(REPLACE(@VALUES,',',',,'))-LEN(@VALUES)
IF(@COUNTA@COUNTB)
--2个表比较
DECLARE @SourceTableName VARCHAR(100)
DECLARE @DestTableName VARCHAR(100)
SET @SourceTableName = 'TableA'
SET @DestTableName = 'TableB'
SELECT A.TABLE_NAME AS SourceTable
,A.COLUMN_NAME AS SourceColumn
,A.DATA_TYPE AS SourceType
,B.TABLE_NAME AS DestTable
,B.COLUMN_NAME AS DestColumn
,B.DATA_TYPE AS DestType
FROM (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @SourceTableName) A
FULL OUTER JOIN (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @DestTableName) B
ON A.COLUMN_NAME = B.COLUMN_NAME AND A.DATA_TYPE = B.DATA_TYPE
WHERE A.TABLE_NAME IS NULL OR B.TABLE_NAME IS NULL