CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching language of SQL
SQL
echo Running prop 104 again even though it is done
timex dbaccess $DB_NAME<<!
execute procedure gamtrpcmp_convert(104,1000,24);
!
Thursday @ 9:17am
Tags:
3 Views
no comments
 
SQL
DECLARE
     @StartDate DATETIME
    ,@EndDate DATETIME
 
SET @StartDate = '1/26/2012'
SET @EndDate = '1/26/2012';
 
    WITH MultiplePaymentCTE (orderID, TaxPerPayType, ShipPerPayType, DiscountPerPayType, PayTypeCount) AS 
    (
        SELECT 
February 01, 2012 @ 11:57am
Tags:
10 Views
no comments
 
SQL
SELECT oid,pid,ptype,date,status,efamt,
       description   AS descr,
       FORMAT(amt,2) AS amt,
       IFNULL(DATE_FORMAT(date,"%b %d, %Y"),"None") as date
FROM (
    (SELECT ORD1.orders_id   AS oid,
            OCCA.id          AS pid,
            "Credit Card"    AS ptype,
            OCCA.tran_date   AS date,
            "Charged"        AS status,
February 01, 2012 @ 10:46am
Tags:
32 Views
no comments
 
SQL
USE [msdb]
GO
 
/****** Object:  Job [iERP85_ExpandGLPeriods]    Script Date: 02/01/2012 10:45:58 ******/
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
/****** Object:  JobCategory [[Uncategorized (Local)]]]    Script Date: 02/01/2012 10:45:58 ******/
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]' AND category_class=1)
BEGIN
by Brent Pabst   February 01, 2012 @ 7:50am
16 Views
no comments
 
SQL
 
 
 
 /*************************************************************************************
  *
  *        Copyright 2012 Davide Orazio Montersino http://www.davidemontersino.com
  *
  *        This program is free software: you can redistribute it and/or modify
  *        it under the terms of the GNU General Public License as published by
  *        the Free Software Foundation, either version 3 of the License, or
by Davide Orazio Montersino   January 10, 2012 @ 2:19am
27 Views
no comments
 
SQL
  SELECT   *
    FROM   (  SELECT   60 * (EXTRACT (HOUR FROM INSERTED_DATE) - 12)
                       + EXTRACT (MINUTE FROM INSERTED_DATE)
                          AS MINUTE,
                       COUNT (E.ID_EVENT) / 60 AS FRAMESPERSECONDE
                FROM   EVENT E
               WHERE   INSERTED_DATE >
                          TO_TIMESTAMP ('23122011 12:00:00',
                                        'DDMMYYYY HH24:MI:SS')
            GROUP BY   EXTRACT (HOUR FROM INSERTED_DATE),
by tikrimi   December 23, 2011 @ 6:47am
Tags: PO, Orange, T&T
19 Views
no comments
 
SQL
SELECT   INSERTED_DATE
  FROM   (  SELECT   *
              FROM   EVENT E
          ORDER BY   E.INSERTED_DATE DESC)
 WHERE   ROWNUM < 100;
by tikrimi   December 23, 2011 @ 2:47am
Tags: PO, Orange, T&T
26 Views
no comments
 
SQL
CREATE PROC SearchAllTables
(
    @SearchStr nvarchar(100)
)
AS
BEGIN
    CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
 
    SET NOCOUNT ON
by Prithvi Ramana A   December 22, 2011 @ 6:46am
31 Views
no comments
 
SQL
SELECT o.name, c.text FROM sysobjects o INNER JOIN syscomments c ON o.id = c.id  
 WHERE xtype = 'P' AND CharIndex('<KEYWORD>',c.text) > 0 ORDER BY o.name
by jaredmroberts   December 02, 2011 @ 3:38pm
Tags: t-sql
39 Views
no comments
 
SQL
Select * 
From dbo.SysObjects
where xtype = 'P'
by Brian McKay   December 01, 2011 @ 7:47am
Tags:
26 Views
no comments
 
SQL
select name as 'Database Name', [dbid] from master.dbo.sysdatabases
by Egli   November 09, 2011 @ 4:56pm
35 Views
no comments
 
SQL
/*
Since you cant alter the database straight away, you first need to kill the user thats currently connected to it...
So...
Step 1:
Get the session thats connected to that database
*/
 
select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
from master.dbo.sysprocesses p inner join master.dbo.sysdatabases d on p.dbid = d.dbid
where d.name = 'DATABASE NAME GOES HERE'
by Egli   November 01, 2011 @ 5:33pm
32 Views
no comments
 
SQL
 
-- ---
-- Globals
-- ---
 
-- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-- SET FOREIGN_KEY_CHECKS=0;
 
-- ---
-- Table 'tblUsers'
by hbozdogan   October 06, 2011 @ 1:58pm
Tags:
42 Views
no comments
 
SQL
-- Create linked server
EXEC sp_addlinkedserver 
   @server = N'<linked server name>', 
   @srvproduct = N'Oracle', 
   @provider = N'MSDAORA', 
   @datasrc = N'<TNS names>'; 
GO
 
-- Configure linked server credentials
EXEC sp_addlinkedsrvlogin 
by tpeczek   October 03, 2011 @ 11:14am
Tags:
38 Views
no comments
 
SQL
/*
Ordered Jobs Kata http://invalidcast.com/2011/09/the-ordered-jobs-kata
Sherwin Rice 30/09/2011
 
*/
 
USE TempDB
 
/*drop & create the OrderTheJobs function */
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OrderTheJobs]') )
by shockstump   September 30, 2011 @ 9:23am
Tags: kata
86 Views
no comments
 
SQL
 
alter table Table1
add constraint FK_Table1_Table2 FOREIGN KEY ( Fk_Table1Column ) references Table2(PK_Table2Column)
by Egli   September 29, 2011 @ 5:48am
50 Views
no comments
 
SQL
declare @tablevar table(spid int, dbid int, objid int, indid int, [type] varchar(64), resource varchar(64), mode varchar(64), status varchar(64))
insert into @tablevar exec sp_lock
select spid, dbid, ObjId, object_name( objid), IndId, [type], Resource, Mode, Status from @tablevar 
by Steve Scheffler   September 27, 2011 @ 11:58am
Tags: sql, locks
58 Views
no comments
 
SQL
--
-- Dump object names for any locks currently waiting
--
declare @tablevar table(spid int, dbid int, objid int, indid int, [type] varchar(64), resource varchar(64), mode varchar(64), status varchar(64))
insert into @tablevar exec sp_lock
select object_name( objid) from @tablevar where status = 'WAIT'
by Steve Scheffler   September 27, 2011 @ 9:06am
Tags: sql, locks
47 Views
no comments
 
SQL
begin transaction
 
rollback transaction
by Fphillips   September 23, 2011 @ 7:59pm
Tags:
59 Views
no comments
 
SQL
CREATE TABLE IF NOT EXISTS `atbats` (
  `ab_id` mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
  `game_id` smallint(6) unsigned NOT NULL,
  `inning` tinyint(2) unsigned NOT NULL,
  `half` tinyint(1) unsigned DEFAULT '0',
  `num` tinyint(3) unsigned NOT NULL,
  `ball` tinyint(1) unsigned NOT NULL,
  `strike` tinyint(1) unsigned NOT NULL,
  `outs` tinyint(1) unsigned NOT NULL,
  `batter` mediumint(6) unsigned NOT NULL,
by Mike Fast   September 14, 2011 @ 8:12pm
Tags:
168 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate