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
// log an object to the browser console | |
console.log({ text: "foobar" }); |
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 (object_id('Mobility_In_Queue') IS NOT NULL) | |
drop table [Mobility_In_Queue] | |
GO | |
-- *********************************************** | |
-- new table Mobility_In_Queue that holds the | |
-- data/messages uploaded from the mobile devices | |
-- *********************************************** | |
IF NOT EXISTS (select 1 from sysobjects where name = 'Mobility_In_Queue' and [type] = 'U') | |
create table [dbo].[Mobility_In_Queue] ( |
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 not exists (select 1 from syscolumns where name = 'Integrated_Mapping' and ID in (select so.ID from sysobjects so where so.name = 'PRODUCTS' and so.type = 'U') ) | |
alter table PRODUCTS ADD Integrated_Mapping bit NULL | |
GO | |
UPDATE PRODUCTS SET Integrated_Mapping = 0 where (Integrated_Mapping IS NULL) | |
GO | |
if not exists ( select 1 from sysconstraints where constid in | |
(select so.ID from sysobjects so |
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 @coffee TABLE ( | |
spid int | |
, [status] varchar(50) | |
, [Login] varchar(255) | |
, HostName varchar(255) | |
, BlkBy varchar(50) | |
, [DBName] varchar(255) | |
, [Command] varchar(255) | |
, CPUTime int | |
, DiskIO int |
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 @coffee TABLE ( | |
spid int | |
, ecid int | |
, [status] varchar(50) | |
, loginame varchar(255) | |
, hostname varchar(255) | |
, blk varchar(50) | |
, dbname varchar(255) | |
, cmd varchar(255) | |
, request_id int |
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 TableName, | |
p.rows AS RowCounts, | |
SUM(a.total_pages) * 8 AS TotalSpaceKB, | |
SUM(a.used_pages) * 8 AS UsedSpaceKB, | |
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB | |
FROM | |
sys.tables t | |
INNER JOIN | |
sys.indexes i ON t.OBJECT_ID = i.object_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
select so.name, sc.[text] | |
from syscomments sc with (nolock) | |
inner join sysobjects so with (nolock) on so.[id] = sc.[id] | |
where [text] like '%create_job%' | |
/* raw | |
select * from syscomments sc with (nolock) where [text] like '%create_job%' | |
*/ |
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
-- create a new table and insert records | |
-- ===================================== | |
select * into newtablename from MyFirstTable | |
-- copy records into existing table | |
-- ===================================== | |
insert into ReprocessTable(event_time, [msg]) select event_time, [msg] from FailedTable order by [id] | |
-- create a new table with records from another database |
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 object_id('AsXMLAttribute') IS NOT NULL | |
DROP FUNCTION [dbo].[AsXMLAttribute] | |
GO | |
CREATE FUNCTION [dbo].[AsXMLAttribute] ( | |
@text varchar(max) | |
) | |
RETURNS varchar(max) | |
AS | |
BEGIN |
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
// assumes dr is a SqlDataReader | |
List<string> columns_ = GetColumns(dr); | |
if (columns_.IndexOf("MissingField") == -1) { throw new Exception("Query did not contain \"MissingField\""); } | |
this.DBID = (int)dr["ID"]; | |
this.Created = (DateTime)dr["Created"]; | |
this.DataText = (string)dr["MissingField"]; | |
if (!dr.IsDBNull(columns_.IndexOf("MsgType")) { this.MsgType = (string)dr["MsgType"]; } |
OlderNewer