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 @handle UNIQUEIDENTIFIER; | |
WHILE (SELECT COUNT(*) FROM NameOfQueue) > 0 | |
BEGIN | |
RECEIVE TOP (1) @handle = conversation_handle FROM NameOfQueue; | |
END CONVERSATION @handle WITH CLEANUP | |
END |
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 q.name, p.rows | |
FROM sys.partitions p | |
INNER JOIN sys.internal_tables t ON t.object_id = p.object_id | |
INNER JOIN sys.service_queues q ON q.object_id = t.parent_object_id | |
WHERE p.index_id IN (1, 0) --AND q.name = 'QueueName' |
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
var name = "John Doe"; | |
function getFirstName(fullName) { | |
var next = fullName[0]; | |
var i = 0; | |
var length = fullName.length; | |
while (i < length && next !== " ") { | |
console.log(fullName[i]); | |
i++; | |
next = fullName[i]; |
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
--insert into Documents VALUES ('products/1', '<product><name>Foo</name></product>', 'dynamic'); | |
--insert into Documents VALUES ('products/2', '<product><name>Bar</name></product>', 'dynamic'); | |
--insert into Documents VALUES ('products/3', '<product><name>Fizz</name></product>', 'dynamic'); | |
--insert into Documents VALUES ('products/4', '<product><name>Buzz</name></product>', 'dynamic'); | |
UPDATE Documents SET Data = '<product><name>Foo</name></product>', entitytype='dynamic' WHERE Id = 'products/1'; | |
select Data.value('(//product/name)[1]','varchar(30)') from Documents where entitytype = 'dynamic2' | |
select Data.value('(//product/name)[1]','varchar(30)') from Documents | |
select Data.value('(//product/name)[1]','varchar(max)') from Documents |
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 [text], cp.size_in_bytes, plan_handle | |
FROM sys.dm_exec_cached_plans AS cp | |
CROSS APPLY sys.dm_exec_sql_text(plan_handle) | |
WHERE | |
cp.cacheobjtype = N'Compiled Plan' | |
AND cp.objtype = N'Adhoc' | |
AND cp.usecounts = 1 | |
ORDER BY cp.size_in_bytes DESC; |
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
SET NOCOUNT ON | |
DBCC UPDATEUSAGE(0) | |
-- DB size. | |
EXEC sp_spaceused | |
-- Table row counts and sizes. | |
CREATE TABLE #t | |
( |
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
-- Note: querying sys.dm_os_buffer_descriptors | |
-- requires the VIEW_SERVER_STATE permission. | |
DECLARE @total_buffer INT; | |
SELECT @total_buffer = cntr_value | |
FROM sys.dm_os_performance_counters | |
WHERE RTRIM([object_name]) LIKE '%Buffer Manager' | |
AND counter_name = 'Total Pages'; |
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 | |
o.name | |
, indexname=i.name | |
, i.index_id | |
, reads=user_seeks + user_scans + user_lookups | |
, user_seeks | |
, last_user_seek | |
, last_system_seek | |
, user_scans | |
, last_user_scan |
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
SET NOCOUNT ON | |
DBCC UPDATEUSAGE(0) | |
-- DB size. | |
EXEC sp_spaceused | |
-- Table row counts and sizes. | |
CREATE TABLE #t | |
( |
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 | |
q.name AS Queue_Name | |
, s.name AS Service_Name | |
, p.rows AS Row_Count | |
, (p.rows / 2) AS Estimated_Message_Count -- divide by two because our framework always sends an "END CONVERSATION" message with each real message sent | |
, COALESCE(f.Failed_Message_Count,0) AS Failed_Message_Count | |
-- other interesting things | |
--, q.is_enqueue_enabled | |
--, q.is_receive_enabled |