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 tags of Sql
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   Wednesday @ 7:50am
10 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
37 Views
no comments
 
SQL
select name as 'Database Name', [dbid] from master.dbo.sysdatabases
by Egli   November 09, 2011 @ 4:56pm
33 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
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
57 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
46 Views
no comments
 
C#
public static IList<T> ToList<T>(this System.Data.SqlClient.SqlDataReader dr) where T : new()
       {
           Type type = typeof(T);
           if(System.Web.HttpContext.Current.Cache[type.Name + "_properties"] == null)
           {
               System.Web.HttpContext.Current.Cache.Insert(type.Name + "_properties", type.GetProperties().ToList());
           }
           IList<PropertyInfo> properties = (IList<PropertyInfo>)System.Web.HttpContext.Current.Cache[type.Name + "_properties"];
           IList<T> result = new List<T>();
           while(dr.Read())
by ofer   September 25, 2011 @ 3:18am
77 Views
no comments
 
 
ALTER PROCEDURE [dbo].[pr_OrderItem_history] (
@PipCode    varchar(50),
@BarCode    varchar(150),
@Status     Char(10)
)
AS
BEGIN
select 
PID.PO_ItemID,
by Guru   September 24, 2011 @ 2:25am
Tags: CASE, Select, tsql
53 Views
no comments
 
SQL
-----------------------------------------------------------
-----------------------------------------------------------
--- BASIC DATA BASE 
create database Producction
go
use [Producction]
create table Categorias 
(
    Id int identity (1,1)not null
    ,Nombre varchar (100)
by racsonp   September 05, 2011 @ 9:40pm
Tags: sql, TSQL
50 Views
no comments
 
SQL
-----------------------------------------------------------
-----------------------------------------------------------
-- SQL Ccommand's help
select getdate()
select GETUTCDATE ()
set dateformat mdy
select  convert(varchar, Fecha, 106) ,convert(varchar, Fecha, 103) 
 
---Kill tables
by Oscar   September 05, 2011 @ 9:36pm
Tags: sql, TSQL
51 Views
no comments
 
SQL
CREATE Procedure spDeleteRows
/* 
Recursive row delete procedure. 
 
It deletes all rows in the table specified that conform to the criteria selected, 
while also deleting any child/grandchild records and so on.  This is designed to do the 
same sort of thing as Access's cascade delete function. It first reads the sysforeignkeys 
table to find any child tables, then deletes the soon-to-be orphan records from them using 
recursive calls to this procedure. Once all child records are gone, the rows are deleted 
from the selected table.   It is designed at this time to be run at the command line. It could 
by Egli   August 17, 2011 @ 5:50am
94 Views
no comments
 
SQL
/*
Only showing the top 100 for this result
*/
 
SELECT TOP(100) total_worker_time/execution_count AS AvgCPU  
, total_worker_time AS TotalCPU
, total_elapsed_time/execution_count AS AvgDuration  
, total_elapsed_time AS TotalDuration  
, (total_logical_reads+total_physical_reads)/execution_count AS AvgReads 
, (total_logical_reads+total_physical_reads) AS TotalReads
by Egli   July 26, 2011 @ 12:52am
74 Views
no comments
 
SQL
create function dbo.fn_SpacePascal(@in varchar(500)) RETURNS varchar(500)
begin
 
/*
      by: jerry
      on: 5/2011
      to: seperate PascalCaseWords to Pascal Case Words
*/
 
      if (@in COLLATE Latin1_General_CS_AS = UPPER(@in)) 
by Jerry Nixon   July 19, 2011 @ 5:47pm
Tags: TSQL
134 Views
no comments
 
SQL
CREATE  TABLE IF NOT EXISTS `dncms`.`dncms_articles` (
  `article_id` INT(11) NOT NULL AUTO_INCREMENT ,
  `title` TEXT NOT NULL ,
  `body` TEXT NOT NULL ,
  `user_id` INT(11) NULL DEFAULT NULL ,
  `published` TINYINT(4) NULL DEFAULT '0' ,
  `keywords` TEXT NULL DEFAULT NULL ,
  `description` TEXT NULL DEFAULT NULL ,
  `datetime` DATETIME NULL DEFAULT NULL ,
  `language_id` INT(11) NOT NULL ,
by Aria Radmand   July 12, 2011 @ 11:25pm
99 Views
no comments
 
C#
var x = _context.Database.SqlQuery<Company>("SELECT * FROM Companies").ToList();
by biboyatienza   June 22, 2011 @ 2:19am
169 Views
no comments
 
SQL
select * from INFORMATION_SCHEMA.COLUMNS where table_name not like 'v%' order by TABLE_NAME, ORDINAL_POSITION
 
select * from INFORMATION_SCHEMA.ROUTINES
 
select * from INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE
select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
 
SELECT s.name [SPECIFIC_SCHEMA], o.name [SPECIFIC_NAME], s.name [ROUTINE_SCHEMA], o.name [ROUTINE_NAME], 
case when o.[type] in ('P', 'PC') then 'PROCEDURE' 
when o.type in ('V') then 'VIEW' 
by Thom Lamb   June 13, 2011 @ 8:10am
80 Views
no comments
 
        Partial MustInherit Class InformationSchema
            Inherits System.Data.Linq.DataContext
 
            Private Shared mappingSource As System.Data.Linq.Mapping.MappingSource = New AttributeMappingSource
 
#Region " Constructors "
 
            Public Sub New(ByVal connection As String)
                MyBase.New(connection, mappingSource)
            End Sub
by Thom Lamb   June 09, 2011 @ 8:44am
182 Views
no comments
 
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Linq
Imports System.Data.Linq.Mapping
Imports System.IO
Imports System.Linq
Imports System.Text
Imports System.Diagnostics
Imports System.Reflection
by Thom Lamb   June 09, 2011 @ 8:40am
258 Views
no comments
 
SQL
SELECT * FROM OPENQUERY(ADSI, 
'SELECT objectCategory, cn, givenName, sn, mail, name, department,SAMAccountName FROM 
''LDAP://DC=<<DOMAIN>>,DC=<<COM,LOCAL,NET>>'' 
WHERE  objectClass = ''group'' ORDER BY cn')
AS ADGroups
by jaredmroberts   June 08, 2011 @ 4:03pm
Tags: AD, T-SQL
146 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