gavilanch2 gavilanch2 29-05-2022 12:00
(Visitas: 19)



Computin Computin 04-01-2021 06:52
(Visitas: 24)

Estructura de la tabla original

MESNOMBREMONTO
1JUAN2000
1PEDRO4000
1DIEGO7000
3PEDRO1000
2PEDRO6000
2JUAN8000

consulta sql: select Nombre, [1] AS ENERO,[2] AS FEBRERO,[3] AS MARZO From (Select Nombre,Monto,Mes from Pagos) as TablaFuente PIVOT (SUM(Monto) For MES in ([1],[2],[3])) as TablaPivote

NombreENEROFEBREROMARZO
DIEGO7000NULLNULL
JUAN20008000NULL
PEDRO400060001000


Computin Computin 04-01-2021 06:36
(Visitas: 23)

USE msdb;
GO
SELECT items.subject,
items.last_mod_date
,l.description FROM dbo.sysmail_faileditems as items
INNER JOIN dbo.sysmail_event_log AS l
ON items.mailitem_id = l.mailitem_id
WHERE items.recipients LIKE '%gmail%'
OR items.copy_recipients LIKE '%gmail%'
OR items.blind_copy_recipients LIKE '%gmail%'
order by items.last_mod_date


Computin Computin 04-01-2021 02:39
(Visitas: 26)

A veces cuando usamos cursores dinamicos, por ejemplo:

SET @strOpenRowSet = 'SELECT * FROM OPENROWSET (' + '''Microsoft.ACE.OLEDB.12.0''' +',' + '''Excel 8.0;Database=' + @strPath+@strArchivo + ';HDR=Yes, imex=1'''+','+ '''SELECT * FROM [usuarios$]''' + ')'
SET @strSQL = 'DECLARE c_reg_xls CURSOR STATIC FOR '  + @strOpenRowSet

EXECUTE sp_executesql @strSQL

el cursor se ejecuta de modo local no como global, entonces para evitar el error se usa esta sentencia para dejar los cursores globales

ALTER DATABASE [ops_cmpcpec_v60]
SET CURSOR_DEFAULT GLOBAL


hdeleonnet hdeleon.net 16-12-2020 12:08
(Visitas: 25)

En este video te mostrare un mecanismo existente en SQL Server con el cual puedes cargar masivamente datos por medio de un archivo de texto plano, por ejemplo un archivo CSV.



Música destacada