Skip to content

Instantly share code, notes, and snippets.

View mvillegascuellar's full-sized avatar

Michael Villegas mvillegascuellar

View GitHub Profile
@mvillegascuellar
mvillegascuellar / sqlserveralerts.sql
Created September 28, 2019 03:12
sqlserveralerts
/*
USE [msdb]
GO
/****** Object: Operator [DL_Peru_Operations] Script Date: 01/25/2013 08:26:18 ******/
EXEC msdb.dbo.sp_add_operator @name=N'DL_Peru_Operations',
@enabled=1,
@weekday_pager_start_time=90000,
@weekday_pager_end_time=180000,
create index ix1_spe_summaryheader on dbo.spe_summaryheader (bl_estadoRegistro) INCLUDE (tipoDocumentoEmisor, numeroDocumentoEmisor, resumenId, bl_origen, bl_reintento);
create index ix1_spe_einvoiceheader on dbo.SPE_EINVOICEHEADER (bl_estadoRegistro) INCLUDE (tipoDocumentoEmisor,numeroDocumentoEmisor, tipoDocumento, serieNumero, bl_origen, bl_reintento);
create index ix1_spe_service_response on dbo.spe_service_response (process_state desc, running, next_try, reintento )
include (tipoDocumentoEmisor, numeroDocumentoEmisor, tipoDocumento, serieNumero, origen, bl_hashFirma, bl_firma, bl_estadoRegistro, bl_estadoProceso, bl_ubl,ubl_state, bl_xml, xml_state)
-- create index ix1_spe_service_response on dbo.spe_service_response (process_state desc, running, next_try, reintento ) ;
create index ix1_spe_summary_response on dbo.spe_summary_response (process_state desc, running, next_try, reintento)
include (tipoDocumentoEmisor, numeroDocumentoEmisor, resumenId, origen, bl_hashFirma, bl_firma, bl_estadoRegist
EXEC sp_configure 'show advanced options', 1;
GO
RECONFIGURE
GO
EXEC sp_configure 'Agent XPs', 1;
GO
RECONFIGURE
GO
DECLARE @daysleft int
DECLARE @instancename sysname
# Declaro algunas variables
$NuevoDS = '/NuevaCarpeta/Data Sources/Default'
$rsuri = 'http://MiServidorSSRS/ReportServer'
$NuevaCarpetaSSRS = '/NuevaCarpeta'
# Obtengo los reportes de la Nueva carpeta SSRS
$reports = Get-RsFolderContent -ReportServerUri $rsuri -RsFolder $NuevaCarpetaSSRS | Where-Object TypeName -EQ 'Report'
# Cambio el Datasource que tiene por el nuevo DS
$reports | ForEach-Object {
# Declaro algunas variables
$rsuri = 'http://MiServidorSSRS/ReportServer'
$CarpetaLocal = 'F:\Tmp\SSRS'
$CarpetaDestinoSSRS = '/NuevaCarpeta'
# Cargo los reportes
Write-RsFolderContent -ReportServerUri $rsuri -Path $CarpetaLocal -Destination $CarpetaDestinoSSRS -Verbose
# Definir algunas variables
$rsuri = 'http://MiServidorSSRS/ReportServer'
# Guardar los reportes de la carpeta original en una variable
$reports = Get-RsFolderContent -ReportServerUri $rsuri -RsFolder '/CarpetaOriginal' |
Where-Object TypeName -EQ 'Report'
# Descargar los reportes en una carpeta local
$reports | ForEach-Object { Out-RsCatalogItem -ReportServerUri $rsuri -RsItem $_.Path -Destination 'F:\Tmp\SSRS' }
install-module ReportingServicesTools
-- creamos las variables tipo tabla
DECLARE @tmp1 TABLE (object_id int, name sysname)
DECLARE @tmp2 TABLE (object_id int, column_id int, name sysname)
-- insertamos la informacion en las variables tipo tabla
insert into @tmp1
select object_id, name
from sys.all_objects
insert into @tmp2
select object_id, column_id, name
-- creamos tabla temporal 1 y la llenamos
select object_id, name
into #tmp1
from sys.all_objects
-- creamos tabla temporal 2 y la llenamos
select object_id, column_id, name
into #tmp2
from sys.all_columns
select
DB_NAME(mf.database_id)
,sum(fs.num_of_reads) as total_reads
from sys.master_files mf
cross apply sys.dm_io_virtual_file_stats(mf.database_id,NULL) fs
where mf.database_id = 2
and mf.type_desc = 'ROWS'
group by mf.database_id
GO
DECLARE @temp1 TABLE (col1 int)