Kategoria: SQL Server

Administracja, Przydatne skrypty, SQL Server

Autogrowth events – skrypt na detale rozrostu MDF / NDF i LDF z default trace’a

Znalezione na stronie The SQL Guy by Norm Enger   USE [master]; GO BEGIN TRY IF ( SELECT CONVERT(INT, value_in_use) FROM sys.configurations WHERE name = 'default trace enabled’ ) = 1 BEGIN DECLARE @curr_tracefilename VARCHAR(500); DECLARE @base_tracefilename VARCHAR(500); DECLARE @indx INT; SELECT @curr_tracefilename = path FROM sys.traces WHERE is_default = 1;Czytaj dalej / Read more

Przydatne skrypty, SSIS, SSISDB

Raport z czasami procesowania paczek ETLowych z SSISDB

Skrypt dzięki uprzejmości Michała Powagi 😉 — raport z czasami procesowania paczek ETLowych USE SSISDB; GO SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; DECLARE @execution_id BIGINT = 70660; — tutaj wstawić execution ID paczki WITH msgs AS ( SELECT event_message_id , execution_path , package_name , package_path_full , event_name , message_source_name ,Czytaj dalej / Read more

Administracja, Development, Przydatne skrypty, SQL Server

RESTORE DATABASE FROM database_snapshot

Z dokumentacji technet: https://msdn.microsoft.com/en-us/library/ms175158%28v=sql.105%29.aspx Snapshots can be used for reporting purposes. Also, in the event of a user error on a source database, you can revert the source database to the state it was in when the snapshot was created. Data loss is confined to updates to the database sinceCzytaj dalej / Read more

Administracja, Development, SQL Server

TRUNCATE tylko części danych? Challenge accepted!

UWAGA Artykuł pochodzi z czasów, gdy nie istniało polecenie TRUNCATE TABLE WITH PARTITIONS . Dlatego został on nieco zmodyfikowany, odpowiednie komentarze prostują sytuację ;] Z dokumentacji technet: https://msdn.microsoft.com/pl-pl/library/ms189461%28v=sql.110%29.aspx Partitioning data enables you to manage and access subsets of your data quickly and efficiently while maintaining the integrity of the entire dataCzytaj dalej / Read more

Development, SQL Server

Zaawansowane przesuwanie okien :D (czyli użycie funkcji „okienkowych” OVER i zastosowanie ROWS,RANGE,BETWEEN,UNBOUNDED, CURRENT, PRECEDING, FOLLOWING)

Z dokumentacji technet: https://msdn.microsoft.com/pl-pl/library/ms189461%28v=sql.110%29.aspx ROWS | RANGE Further limits the rows within the partition by specifying start and end points within the partition. This is done by specifying a range of rows with respect to the current row either by logical association or physical association. Physical association is achieved byCzytaj dalej / Read more

Development, SQL Server

Potęga funkcji okna – SELECT LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE()

Z dokumentacji technet: https://msdn.microsoft.com/en-us/library/hh231256.aspx https://msdn.microsoft.com/en-us/library/hh213125.aspx https://msdn.microsoft.com/en-us/library/hh213018.aspx https://msdn.microsoft.com/en-us/library/hh231517.aspx LAG provides access to a row at a given physical offset that comes before the current row. LEAD provides access to a row at a given physical offset that follows the current row. FIRST_VALUE returns the first value in an ordered set ofCzytaj dalej / Read more