This file contains hidden or 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 'exec sp_rename N''dbo.[' + d.name + ']'', ''DF_' + upper(t.name) + '_' + lower(c.name) + ''';' cmd | |
from sys.tables t | |
join sys.columns AS c on c.object_id = t.object_id | |
JOIN sys.default_constraints AS d on d.parent_object_id = t.object_id and d.parent_column_id = c.column_id | |
where t.schema_id = 1 | |
and d.name <> 'DF_' + upper(t.name) + '_' + lower(c.name) | |
order by 1 |
This file contains hidden or 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
BEGIN | |
set quoted_identifier on | |
DECLARE @db varchar(max) = 'MyDB' | |
DECLARE @today VARCHAR(9) = datename(w,sysdatetime()) | |
DECLARE @tableName varchar(max) | |
DECLARE @indexName varchar(max) | |
DECLARE @sql Nvarchar(max) | |
This file contains hidden or 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
BEGIN | |
SELECT [name], [recovery_model_desc], sys.fn_hadr_is_primary_replica([name]) as [pr] FROM sys.databases | |
DECLARE @db VARCHAR(128) | |
DECLARE @targets TABLE (db varchar(128)) | |
INSERT INTO @targets (db) VALUES ('MyDB'), ('YourDB') | |
DECLARE c CURSOR FOR | |
SELECT [db] FROM @targets |
This file contains hidden or 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 @db VARCHAR(128) | |
DECLARE c CURSOR FOR | |
SELECT [name] FROM sys.databases | |
WHERE recovery_model_desc = 'FULL' | |
AND [name] NOT IN ('master','msdb','model','tempdb','aspstate') | |
OPEN c | |
FETCH NEXT FROM c INTO @db | |
This file contains hidden or 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
import requests | |
import os | |
import math | |
key=os.environ['GOOGLE_API_KEY'] | |
address='1600 Pennsylvania Ave NW, Washington, DC 20500' | |
endpoint='https://maps.googleapis.com/maps/api/geocode/json?' | |
response = requests.get(endpoint + 'address=' + address + '&key=' + key) | |
location=response.json()['results'][0]['geometry']['location'] |
This file contains hidden or 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 blocked as ( | |
SELECT pid AS blocked_pid | |
, usename AS blocked_username | |
, query AS blocked_query | |
, query_start AS blocked_start | |
, wait_event AS blocked_wait_event | |
, wait_event_type AS blocked_event_type | |
, unnest( pg_blocking_pids( pid ) ) AS blocked_by | |
FROM pg_stat_activity | |
WHERE cardinality( pg_blocking_pids( pid ) ) > 0 |
This file contains hidden or 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 * | |
from pg_stat_activity | |
where (state = 'idle in transaction') | |
and xact_start is not null ; |
OlderNewer