As a database designer, I often create on database tables the primary key as identity autoincrement and sometimes I needed to find missing or deleted IDs thet interrupt the sequence…
As a database designer, I often create on database tables the primary key as identity autoincrement and sometimes I needed to find missing or deleted IDs thet interrupt the sequence…
When you modify database schema on Sql Server with Microsoft SQL Server Management Studio you can simply create script with Generate Change Script function. This is not allowed when you…
The following snippet shows how to find identity columns inside database. You can also apply where condition to filter on a table name. SELECT * FROM sys.tables T INNER JOIN…
T-SQL: Alcuni accorgimenti per migliorare le prestazioni delle interrogazioni al database Spesso scriviamo query senza badare tanto alle performance, non tanto in termini di query (che è comunque importante), ma…
Spesso mi è servito impostare una data al valore Maxdate (31/12/9999 23.59.59) da statement SQL. Lo snippet è il seguente: UPDATE TABELLA SET DATA = CAST('9999-12-31 23:59:59' AS DATETIME) Analogamente…
Di recente mi è capitato di ricevere il seguente errore in fase di creazione di un diagramma di un database ripristinato a partire da un bakup: Database diagram support objects…
Quando si effettua una transazione è bene associarla ad un blocco TRY .. CATCH.. ed ottenere l'eventuale errore che scatena il ROLLBACK della transazione. Ecco lo snippet di esempio: USE…