topogigiovanni
4/4/2018 - 12:48 PM

select em todas as bases CORE

faz consula em todas as bases do CORE

pesauisa em todos os bancos

sp_MSForEachDB 
'USE [?]
IF OBJECT_ID(N''configurations'', N''U'') IS NOT NULL
BEGIN 
	SELECT ''?'' AS [Database],* FROM banners WHERE IsEnabled = 1 AND BannerPath LIKE ''%.swf%''
END'

--- ou no sql-services no ezportal

  EXEC [dbo].[pForEach] 'PRD', 'USE [?]  
  IF OBJECT_ID(''[billing].[v_billing_orders_month]'') IS NOT NULL  
  BEGIN
	  SELECT ''?'' as dbname, PaymentYear, PaymentMonth, OrdersClosedValue
	 from billing.v_billing_orders_month (nolock)
	where 1=1
	and PaymentYear = 2021 
	and PaymentMonth in (8,9,10)
  END'