IF OBJECT_ID('V_GWEB_SCRIPTS_TOT_SQLSERVER') IS NOT NULL
	DROP VIEW V_GWEB_SCRIPTS_TOT_SQLSERVER
	
GO

CREATE VIEW V_GWEB_SCRIPTS_TOT_SQLSERVER AS
	SELECT COALESCE(SS.STS_SCRIPT, 0) AS STATUS, COUNT(*) AS TOTAL
	FROM  DSYNC_CH_SCRIPTS SC
	LEFT JOIN DSYNC_CH_SCRIPTS_STATUS SS
		ON SS.CRC_FILE = SC.CRC_FILE
	WHERE SC.DB_ID IN (1,2,3)
	GROUP BY SS.STS_SCRIPT