Thứ Ba, 16 tháng 1, 2024

Disable Fips Algorithm Policy ASP.NET

- Solution 1: Disable FipsAlgorithmPolicy in Windows Registry:
  Set Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy\Enabled to 0

- Solution 2: Modify C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Aspnet.config

  <configuration>
    <runtime>
        <enforceFIPSPolicy enabled="false" />
    </runtime> 
</configuration>

Reference:

Chủ Nhật, 24 tháng 12, 2023

[SQL Server] Find Currently Running Queries

SELECT 
	DB_NAME(req.database_id) as db_name
	,sqltext.text
    ,req.session_id
    ,req.status
    ,req.command
	,req.start_time
    ,req.cpu_time
    ,req.total_elapsed_time
	,queryplan.query_plan
	,c.client_net_address
	,s.login_name
	,s.login_time
	,s.program_name
	,s.host_name
	,s.host_process_id
	,s.client_interface_name
	,s.client_version
	--,req.*
	--,c.*
	--,s.*
FROM sys.dm_exec_requests req
JOIN sys.dm_exec_connections c on req.connection_id = c.connection_id
JOIN sys.dm_exec_sessions s on req.session_id = s.session_id
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext
CROSS APPLY sys.dm_exec_query_plan(req.plan_handle) as queryplan

Thứ Tư, 19 tháng 4, 2023

[SQL Server] Convert DateTimeOffset to DateTime

declare @dateTime datetime2 = SYSDATETIME()
declare @dateTimeOffset datetimeoffset = SYSDATETIMEOFFSET()
 
select @dateTime as [CurrentDateTime],
@dateTimeOffset as [CurrentDateTimeOffset],
CAST(@dateTimeOffset as datetime2) as [DateTime1]


select CAST('2023-04-19 15:32:31.2721255 +07:00' as datetime2) -- Output: 2023-04-19 15:32:31.2721255
select CAST('2023-04-19 15:32:31.2721255 +08:00' as datetime2) -- Output: 2023-04-19 15:32:31.2721255

select SWITCHOFFSET('2023-04-19 15:32:31.2721255 +07:00', '+01:00') -- Output: 2023-04-19 09:32:31.2721255 +01:00
select SWITCHOFFSET('2023-04-19 15:32:31.2721255 +08:00', '+01:00') -- Output: 2023-04-19 08:32:31.2721255 +01:00

select CAST(SWITCHOFFSET('2023-04-19 15:32:31.2721255 +07:00', '+01:00') as datetime2) -- Output: 2023-04-19 09:32:31.2721255
select CAST(SWITCHOFFSET('2023-04-19 15:32:31.2721255 +08:00', '+01:00') as datetime2) -- Output: 2023-04-19 08:32:31.2721255

Thứ Ba, 2 tháng 8, 2022

[SQL Server] Convert DateTime to DateTimeOffset

declare @dateTime datetime2 = SYSDATETIME()
declare @dateTimeOffset datetimeoffset = SYSDATETIMEOFFSET()

select @dateTime as [CurrentDateTime],
@dateTimeOffset as [CurrentDateTimeOffset],
CAST(@dateTime as datetimeoffset) as [DateTimeOffset1],
TODATETIMEOFFSET(@dateTime, '+07:00') as [DateTimeOffset2],
TODATETIMEOFFSET(@dateTime, RIGHT(SYSDATETIMEOFFSET(), 6)) as [DateTimeOffset3]

Thứ Ba, 7 tháng 9, 2021

[C#] The request was aborted: Could not create SSL/TLS secure channel

 - Create tls-ssl-settings.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions"=dword:00000001
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions"=dword:00000001
"SchUseStrongCrypto"=dword:00000001
- Execute the reg file.
- Done.

Links: