Monday, 1 February 2021

Reduce SSMS startup time

To reduce the SQL Server Management Studio (SSMS) startup time do following:

1. Edit Shortcut tu start SSMS and append this startup parameter: -nosplash
2. Open system Internet options, go to the Advanced tab and uncheck "Check for server certificate revocation" - this change reuqires system restart.

After that both changes startup time (by me) is 10 times shorter

Additionaly you can reduce clicks by predefine other startup parameters.
For example for localhost, trusted connection and USE of MyDatabase:
..../SSMS.exe -S . -E -d MyDatabase -nosplash

I also set this option:
SSMS Menu / Tools / Option / Environmen / Startup / At statrup = "Open Object Explorer and query window"

Tuesday, 28 January 2020

Google Chrome - Managed by your organization - how to remove?

In some organisations your Web Browser is limited by your organisation.
For example can be deactivated Sync, or switched off geo-location, or disabled installation of some extensions.
you can check it like there: support.google.com: is_chrome_managed?
There are two places in Windows Registry where these policies could be set:

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\
HKEY_CURRENT_USER\SOFTWARE\Policies\Google\Chrome\

To remove these Registry keys and start browser again can does not help. Mach better is to set values. For example like there:
DefaultGeolocationSetting = 3
PasswordManagerEnabled = 1
SyncDisabled = 0
BuiltInDnsClientEnabled = 1

Monday, 13 January 2020

VMware and Chrome - damaged or washed out colors or transparent backgrounds

Sometimes in the Google Crome in VMware Virtual Machine the colors are damaged or washed out or backgrounds are transparent.
For example correct:

and incorrect (background looks to be transparent):

How to solve it?
I know three methods:
1. Switch off 3D Graphics Acceleration in VMware Virtual Machine Settings (you need first shutdown the VM:

2. The worst solution: In Chrome Flags change flag "force color profile" to "scRGB linear (HDR where available)"
(write in address line chrome://flags/ and then search for "force color profile"):

3. My preferred: In Chrome Flags change flag "Choose ANGLE graphics backend" to "OpenGL"
(write in address line chrome://flags/ and then search for "ANGLE"):

Tuesday, 25 July 2017

MSSQL - How to clear all caches?

Script to clear all caches? (For example for performance debug)

/*
https://yabele.blogspot.com/2017/07/mssql-how-to-clear-all-caches.html
*/
SET NOCOUNT ON;
DECLARE @StartedAt DATETIME2 = GETDATE();
CHECKPOINT; 
DBCC DROPCLEANBUFFERS;
DBCC FREESYSTEMCACHE ('ALL');
-- Query
PRINT '    Elapsed time: ' + CAST(DATEDIFF(ms, @StartedAt, GETDATE()) AS VarChar(20)) + ' ms';

MSSQL - T-SQL equivalent of VBA VAL() function

There the text of scalar-value function to extract numbers from string and convert to integer:

IF OBJECT_ID(N'dbo.fn_extract_digits') IS NOT NULL
  DROP FUNCTION dbo.fn_extract_digits;
GO

CREATE FUNCTION dbo.fn_extract_digits (@str VARCHAR(MAX))
/*
https://yabele.blogspot.com/2017/07/mssql-t-sql-equivalent-of-vba-val.html
*/
RETURNS INT
AS
BEGIN
  DECLARE
    @newstr VARCHAR(MAX) = '',
    @i INT = 1,
    @chr CHAR(1);

  WHILE @i <= LEN(@str) BEGIN
    SET @chr = SUBSTRING(@str, @i, 1);
    IF @chr BETWEEN '0' AND '9'
      SET @newstr = @newstr + @chr;
    SET @i = @i + 1;
  END;

  RETURN CAST(@newstr AS INT);
END
/*
DECLARE @str VARCHAR(MAX) = '1-23-456';
SELECT Digits = dbo.fn_extract_digits(@str);*/
;

MSSQL - Function to generate empty rows

There the text of inline table-value function to generate a specified count of empty rows:

IF OBJECT_ID(N'dbo.GenerateRows') IS NOT NULL
  DROP FUNCTION dbo.GenerateRows;
GO
CREATE FUNCTION dbo.GenerateRows (@Count INT)
/*
https://yabele.blogspot.com/2017/07/mssql-function-to-generate-empty-rows.html
*/
RETURNS TABLE
AS
RETURN
WITH TenRows AS (
  SELECT * FROM (VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)) AS T(I)
)
SELECT TOP(@Count)
  I = ROW_NUMBER() OVER(ORDER BY (SELECT 1))
FROM
  TenRows T1 CROSS JOIN TenRows T2 CROSS JOIN TenRows T3 CROSS JOIN TenRows T4 CROSS JOIN TenRows T5
/*
SELECT * FROM dbo.GenerateRows(100);
*/
;

Wednesday, 24 August 2016

MSSQL - How to generate range of Dates

There the text of VIEW to generate range of dates between 1.January 2000 and 31.December next year:

IF OBJECT_ID(N'dbo.calendar_dates') IS NOT NULL
  DROP VIEW  dbo.calendar_dates;
GO
/*
http://yabele.blogspot.de/2016/08/how-to-generate-range-of-dates.html
*/
CREATE VIEW dbo.calendar_dates
AS
WITH
  R10 AS (
    SELECT * FROM (VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)) AS T(I)
  )
SELECT TOP(DATEDIFF(DAY, '2000-01-01', CAST(YEAR(GETDATE()) + 1 AS CHAR(4)) + '-12-31'))
  date_value = DATEADD(DAY, ROW_NUMBER() OVER(ORDER BY (SELECT 1)), '1999-12-31')
FROM
  R10 T1 CROSS JOIN R10 T2 CROSS JOIN R10 T3 CROSS JOIN R10 T4 CROSS JOIN R10 T5 CROSS JOIN R10 T6
/*
SELECT *
FROM dbo.calendar_dates
ORDER BY date_value;
*/
;