This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
deqs.last_execution_time AS [Time] | |
,dest.TEXT AS [Query] | |
FROM sys.dm_exec_query_stats AS deqs | |
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest | |
ORDER BY deqs.last_execution_time DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
SYSLANG_LCID | |
-- ,SYSLANG_Name | |
,SYSLANG_IetfLanguageTag AS IETF | |
--,SYSLANG_TwoLetterISOLanguageName | |
--,SYSLANG_ThreeLetterISOLanguageName | |
--,SYSLANG_ThreeLetterWindowsLanguageName | |
,SYSLANG_EnglishName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;WITH CTE AS | |
( | |
SELECT | |
0 AS i | |
,CAST('A0' AS varchar(10)) AS paper_format | |
,841e AS width | |
,1189e AS height | |
,841e AS orig_width | |
,1189e AS orig_height |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://www.mssqltips.com/sqlservertip/6828/sql-server-login-user-permissions-fn-my-permissions/ | |
-- List all permissions | |
-- SELECT * FROM sys.fn_builtin_permissions(DEFAULT); | |
-- SELECT DISTINCT permission_name FROM sys.fn_builtin_permissions(DEFAULT) ORDER BY permission_name; | |
-- show the different classes | |
SELECT DISTINCT parent_class_desc FROM sys.fn_builtin_permissions(DEFAULT); | |
-- SELECT * FROM sys.fn_builtin_permissions(DEFAULT) WHERE NULLIF(parent_class_desc, '') IS NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb | |
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
base_sch.name AS object_schema | |
,base_obj.name AS object_name | |
,base_obj.type_desc object_type | |
,ref_sch.name AS ref_schema | |
,ref_obj.name AS ref_name | |
,ref_obj.type_desc AS ref_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://satoricyber.com/postgres-security/postgres-row-level-security/ | |
-- https://www.enterprisedb.com/postgres-tutorials/how-implement-column-and-row-level-security-postgresql | |
CREATE TABLE information_under_dataprotection_law | |
( | |
id int not null constraint pk_information_under_dataprotection_law primary key | |
,tenant_id int not null | |
,txt national character varying(4000) not null | |
,val float not null | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- if I have the bellow table in a multi-tenant application, how do i prevent data-leaks | |
-- if in the future, one or more sql-queries on this table forget to where tenant_id = x | |
-- https://www.sqlshack.com/introduction-to-row-level-security-in-sql-server/ | |
-- https://learn.microsoft.com/de-de/sql/relational-databases/security/row-level-security?view=sql-server-ver16 | |
DROP FUNCTION IF EXISTS dbo.generate_series; | |
GO | |
CREATE FUNCTION dbo.generate_series |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @likeStatement nvarchar(4000); | |
SET @likeStatement = '%SearchText%'; | |
SELECT | |
isv.TABLE_SCHEMA | |
,isv.TABLE_NAME | |
,tDef.def | |
FROM INFORMATION_SCHEMA.VIEWS AS isv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- SELECT dbo.AesEncrypt(''), dbo.AesDecrypt('615ca4a4b3e23e5b500ff7352a519e39') | |
-- SELECT dbo.DesEncrypt('test'), dbo.DesDecrypt('WNSw7KxMxW4=') | |
;WITH CTE_PlainText AS | |
( | |
SELECT i, REPLICATE('A', i) AS plainText FROM tfu_RPT_All_Interval(0, 99,1) | |
) |