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
-- sử dụng bản gốc | |
UPDATE TargetTable | |
SET | |
Name = 'XXX' | |
FROM | |
TargetTable parentTable | |
INNER JOIN TargetTable | |
ON | |
parentTable.id = TargetTable.parent_id | |
WHERE |
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
INSERT INTO TargetTable ( | |
id | |
,NAME | |
) | |
SELECT id | |
,NAME | |
FROM SourceTable AS S | |
WHERE NOT EXISTS ( |
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 t.NAME AS table_name | |
,SCHEMA_NAME(schema_id) AS schema_name | |
,c.NAME AS column_name | |
FROM sys.tables AS t | |
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID | |
WHERE c.NAME LIKE '%EmployeeID%' | |
ORDER BY schema_name | |
,table_name; |
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 CASE PS.database_id | |
WHEN 32767 | |
THEN 'Resource DB' | |
ELSE DB_NAME(PS.database_id) | |
END AS [DB Name] | |
,OBJECT_NAME(PS.object_id, PS.database_id) AS [SP Name] | |
,PS.last_execution_time AS [Last Executed] | |
,PS.execution_count AS [# runs] | |
FROM sys.dm_exec_procedure_stats PS | |
ORDER BY DB_NAME(PS.database_id) |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
NewerOlder