tips & tricks


Calendario
aprile 2024
lmmgvsd
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Cursor

Esempio di come usare un cursore:DECLARE @opttype TABLE (code varchar(100),name varchar(300),systemoid varchar(300),description varchar (500),virtual bit,isdigitalized bit,isexternal bit )insert into @opttype (Code,Name,SystemOid,Description,Virtual,IsDigitalized,IsExternal) values('18','internal','test','',0,0,0),('30','internal','test','',0,0,0),('80','internal','test','',0,0,0),('81','internal','test','',0,0,0),('82','internal','test','',0,0,0)DECLARE @code varchar(100),@name varchar(300),@sy 
Leggi tutto il post...
Categoria: SQLServer
giovedì, 11 giu 2020 Ore. 12.26

BACKUP DATABASE

BACKUP AND RESTORE sintaxBACKUP DATABASE [dbname] TO  DISK = N'D:\Database\Backup\20180102_dbname.bak' WITH  COPY_ONLY, NOFORMAT, INIT,  NAME = N'dbname-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10GOdeclare @backupSetId as intselect @backupSetId = position from msdb..backupset where database_name=N'dbname' and backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'dbname' )if @backupSetId is null begin raiserror(N'Verify failed. Ba 
Leggi tutto il post...
Categoria: SQLServer
martedì, 09 gen 2018 Ore. 11.19

Una sorta di group by ma più efficace

SELECT *,ROW_NUMBER() OVER (PARTITION BY idtestata ORDER BY ISNULL(Versione,0) DESC) AS MaxVersioneFROM table TWHERE datacreazione BETWEEN GETDATE()-1 and GETDATE() or CONVERT(DATE,datacreazione) = CONVERT(DATE,GETDATE() )ORDER BY idtestata,datacreazione desc 
Leggi tutto il post...
Categoria: SQLServer
venerdì, 24 giu 2011 Ore. 10.18

Per rendere dei filtri opzionali

WHERE        GC.IdAzienda = @IdAzienda    AND        ISNULL(GC.Brand,'') = ISNULL(@CodiceProduttore,ISNULL(GC.Brand,''))    AND        ISNULL(GC.CategoriaMerceologica,'') = ISNULL(@CatMerc,ISNULL(GC.CategoriaMerceologica,''))    AND        ISNULL(GC.CodiceArticolo,'') = ISNULL(@CodiceArticolo,ISNULL(GC.CodiceArticolo,'')) 
Leggi tutto il post...
Categoria: SQLServer
venerdì, 24 giu 2011 Ore. 10.15

Controllo ISDate()

Normal 0 14 false false false IT X-NONE X-NONE  
Leggi tutto il post...
Categoria: SQLServer
lunedì, 29 nov 2010 Ore. 11.46

CANNOT RESOLVE THE COLLATION CONFLICT

Normal 0 14 false false false IT X-NONE X-NONE  
Leggi tutto il post...
Categoria: SQLServer
mercoledì, 03 nov 2010 Ore. 19.02

UTC

Normal 0 14 false false false IT X-NONE X-NONE  
Leggi tutto il post...
Categoria: SQLServer
giovedì, 28 ott 2010 Ore. 12.59

Gestione degli errori TRY CATCH

Normal 0 14 false false false IT X-NONE X-NONE  
Leggi tutto il post...
Categoria: SQLServer
giovedì, 14 ott 2010 Ore. 12.57

WITH (NOLOCK)

Normal 0 14 false false false IT X-NONE X-NONE MicrosoftInternetExplorer4  
Leggi tutto il post...
Categoria: SQLServer
lunedì, 19 apr 2010 Ore. 11.22

SPLIT di una stringa

Normal 0 14 false false false IT X-NONE X-NONE MicrosoftInternetExplorer4  
Leggi tutto il post...
Categoria: SQLServer
giovedì, 15 apr 2010 Ore. 12.46

Query Dinamiche

Query Dinamiche Normal 0 14 false false false IT X-NONE X-NONE MicrosoftInternetExplorer4  
Leggi tutto il post...
Categoria: SQLServer
giovedì, 15 apr 2010 Ore. 12.39

AutoGrow e AutoShrink

Categoria: SQLServer
giovedì, 23 apr 2009 Ore. 16.39

Transaction Log Enorme

Categoria: SQLServer
giovedì, 23 apr 2009 Ore. 16.38

Ricavare il nome della colonna dal numero

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4  
Leggi tutto il post...
Categoria: SQLServer
venerdì, 05 set 2008 Ore. 11.13

Transaction log file (.ldf)

Transaction log principlesWhenever a data update is made entries are added to the transaction log.It is not possible to prevent this as it is part of the way sql server maintains integrity - particularly during recovery.The transaction log is a circular file i.e. when the end is reached any free entries at the start will be used.This means that all being well the file will stay at a constant size as the current entry cycles round.The system maintains the MinLSN which is a pointer to the first ac 
Leggi tutto il post...
Categoria: SQLServer
venerdì, 01 ago 2008 Ore. 15.07

Spostare i database di un'istanza sql2005

 Hai cannato l'installazione di un'istanza sql e non hai cambiato il default dove andare a piazzare il DB? In effetti è abbastanza facile sbagliare il percorso di installazione del db perchè sql di default ti propone un percorso e non ti chiede se vuoi cambiarlo ma lo devi capire tu nel wizzard, chiaramente se non sei un esperto è facile farselo sfuggire. Il percorso che ti propone lui di default è "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data" che se propio vogliamo  
Leggi tutto il post...
Categoria: SQLServer
venerdì, 18 lug 2008 Ore. 11.54

Maintenance Plan

  E' uno strumento per la manutenzione dei DataBase. Alcuni consigli sono:   1 - Lo Shrink rende il DB molto lento soprattutto in produzione, è una cosa che si fa manualmente quando c’è né bisogno per creare spazio su disco, un po’ come fare la deframmentazione.   2 – Reorganize Index e Rebuild Index insieme non vanno bene perché il rebuild cancella e ricostruisce gli index…. Al massimo si può fare il Reorganize tutti i giorni e il Rebuild una volta a settimana.   3 –& 
Leggi tutto il post...
Categoria: SQLServer
martedì, 03 giu 2008 Ore. 16.37

Istanze per computer SQL2005

  Instances per computer 50 instances on a stand-alone server for all SQL Server 2005 editions except for Workgroup Edition. Workgroup Edition supports a maximum of 16 instances.SQL Server 2005 supports 25 instances on a failover cluster. 50 instances on a stand-alone server.25 instances on a failover cluster. http://msdn2.microsoft.com/en-us/library/ms143432.aspx 
Leggi tutto il post...
Categoria: SQLServer
lunedì, 26 mag 2008 Ore. 14.49

SSIS - Trasferimento di dati da un DB a un'altro

Uno strumento molto comodo per il  trasferimento di dati da un DB ad un'altro sono le trasformazioni SSIS (i vecchi DTS). Si può fare tutto con un designer in visual studio 2005 basta avere installato l'integration service di sql. L'oggetto che ho utilizzato è il Data Flow Task. All'interno del Data Flow ho definito un OleDB Source dove gli passo tutte le coordinate della sorgente da cui devo prelevare i dati. In questo caso una vista creata appositamente per aggregare più in 
Leggi tutto il post...
Categoria: SQLServer
lunedì, 26 mag 2008 Ore. 10.58

Convertire un int in HH:mm

select ar4_realblock ,DATEADD(mi,ar4_realblock,0) -- aggiungo l'int alla data 1900-01-01 ,CONVERT(varchar(5), DATEADD(mi,ar4_realblock,0),8) FROM dbo.FilteredAR4_QuoteFlightDetail Questo però è valido solo entro le 24 ore perchè oltre chiaramente cambia il giorno e si azzarano ore e minuti. Oltre le 24 ore si può usare questo stratagemma, calcolare prima le ore, poi i minuti e poi concatenare le stringhe: cast(ar4_realblock/60 as varchar)+':'+cast((ar4_realblock -((ar4_realblock/60)*6 
Leggi tutto il post...
Categoria: SQLServer
giovedì, 08 mag 2008 Ore. 14.44
Archivio Posts
Anno 2020

Anno 2018

Anno 2015

Anno 2013

Anno 2011

Anno 2010

Anno 2009

Anno 2008
Statistiche
  • Views Home Page: 13.363
  • Views Posts: 56.109
  • Views Gallerie: 2.837
  • n° Posts: 117
  • n° Commenti: 1
Copyright © 2002-2007 - Blogs 2.0
dotNetHell.it | Home Page Blogs
ASP.NET 2.0 Windows 2003