Format:
Recent snippets matching tags of 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
10 Views
no comments
CREATE PROC SearchAllTables ( @SearchStr nvarchar(100) ) AS BEGIN CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630)) SET NOCOUNT ON
31 Views
no comments
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
37 Views
no comments
select name as 'Database Name', [dbid] from master.dbo.sysdatabases
33 Views
no comments
/* 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'
32 Views
no comments
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
57 Views
no comments
-- -- 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'
46 Views
no comments
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())
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,
53 Views
no comments
----------------------------------------------------------- ----------------------------------------------------------- --- BASIC DATA BASE create database Producction go use [Producction] create table Categorias ( Id int identity (1,1)not null ,Nombre varchar (100)
50 Views
no comments
----------------------------------------------------------- ----------------------------------------------------------- -- SQL Ccommand's help select getdate() select GETUTCDATE () set dateformat mdy select convert(varchar, Fecha, 106) ,convert(varchar, Fecha, 103) ---Kill tables
51 Views
no comments
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
94 Views
no comments
/* 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
74 Views
no comments
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))
134 Views
no comments
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 ,
99 Views
no comments
var x = _context.Database.SqlQuery<Company>("SELECT * FROM Companies").ToList();
169 Views
no comments
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'
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
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
258 Views
no comments
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
146 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
