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
| CREATE TABLE #YourTable ([ID] INT, [Name] CHAR(1)) | |
| INSERT INTO #YourTable ([ID],[Name]) VALUES (1,'A') | |
| INSERT INTO #YourTable ([ID],[Name]) VALUES (1,'B') | |
| INSERT INTO #YourTable ([ID],[Name]) VALUES (2,'C') | |
| SELECT | |
| [ID], | |
| STUFF(( | |
| SELECT ', ' + [Name] + '' |
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 | |
| sysobjects.name AS trigger_name | |
| ,USER_NAME(sysobjects.uid) AS trigger_owner | |
| ,s.name AS table_schema | |
| ,OBJECT_NAME(parent_obj) AS table_name | |
| ,OBJECTPROPERTY( id, 'ExecIsUpdateTrigger') AS isupdate | |
| ,OBJECTPROPERTY( id, 'ExecIsDeleteTrigger') AS isdelete | |
| ,OBJECTPROPERTY( id, 'ExecIsInsertTrigger') AS isinsert | |
| ,OBJECTPROPERTY( id, 'ExecIsAfterTrigger') AS isafter | |
| ,OBJECTPROPERTY( id, 'ExecIsInsteadOfTrigger') AS isinsteadof |
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
| Click ctrl H, | |
| enter Find What \n\n+ | |
| enter replace with \n\n | |
| click use regular expression checkbox | |
| click replace all |
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 sys.tables.name,sys.triggers.name,sys.trigger_events.type | |
| ,sys.trigger_events.type_desc, is_first,is_last | |
| ,sys.triggers.create_date,sys.triggers.modify_date | |
| from sys.triggers inner join sys.trigger_events | |
| on sys.trigger_events.object_id = sys.triggers.object_id | |
| inner join sys.tables on sys.tables.object_id = sys.triggers.parent_id | |
| WHERE sys.tables.name LIKE 'INPUT_TABLENAME' | |
| order by modify_date | |
| order of execution of the triggers may depend upon the order of their creation |
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 @a VARCHAR(10) = 'asdf' | |
| DECLARE @b VARCHAR(10) = NULL | |
| SELECT @a + @b, CONCAT(@a, @b) | |
| result | |
| NULL, asdf |
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
| IF EXISTS ( SELECT * | |
| FROM sys.objects o | |
| INNER JOIN sys.procedures p ON o.schema_id = p.schema_id | |
| WHERE o.type = 'P' | |
| AND o.name = 'procedurename' | |
| AND p.schema_id = SCHEMA_ID('schema name') ) | |
| BEGIN | |
| DROP PROCEDURE [schemaname].[procedurename]; | |
| END; | |
| GO |
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 @param NVARCHAR(MAX) | |
| SET @param = '6,7,7,8,10,12,13,14,16,44,46,47,394,396,417,488,714,717,718,719,722,725,811,818,832,833,836,837,846,913,914,919,922,923,924,925,926,927,927,928,929,929,930,931,932,934,935,1029,1072,1187,1188,1192,1196,1197,1199,1199,1199,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1366,1367,1387,1388,1666,1759,1870,2042,2045,2163,2261,2374,2445,2550,2676,2879,2880,2881,2892,2893,2894' | |
| SELECT * FROM | |
| ( | |
| SELECT | |
| DISTINCT Split.a.value('.', 'VARCHAR(100)') AS CVS | |
| FROM | |
| ( | |
| SELECT CAST ('<M>' + REPLACE(@param, ',', '</M><M>') + '</M>' AS XML) AS CVS |
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 sys.objects | |
| WHERE schema_id = SCHEMA_ID('SchemaName'); |
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
| RAISERROR ('Now that''s what I call a message!', 0, 1) WITH NOWAIT |
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 stored_procedures AS ( | |
| SELECT | |
| o.name AS proc_name, oo.name AS table_name, | |
| ROW_NUMBER() OVER(partition by o.name,oo.name ORDER BY o.name,oo.name) AS row | |
| FROM sysdepends d | |
| INNER JOIN sysobjects o ON o.id=d.id | |
| INNER JOIN sysobjects oo ON oo.id=d.depid | |
| WHERE o.xtype = 'P') | |
| SELECT proc_name, table_name FROM stored_procedures | |
| WHERE row = 1 AND stored_procedures.proc_name = 'stprocname' |
NewerOlder