Format:
Recent snippets matching tags of sql
/*--------------------------------------------------------*/ /*------Author:-----ksimons-------------------------------*/ /*------Purpose:----Hurt-Brains---------------------------*/ /*----*/DECLARE @T as Table (i int)Insert into @t /*----*/ /*----*/Select top 1000 ROW_NUMBER()OVER(order by /*----*/ /*----*/s.id) From sysobjects s, sysobjects /*----*/ /*----*/Select Cast(I as varchar)+reverse(substring /*----*/ /*----*/('httsdndr', Cast(((((ceiling((abs(((I/10)- /*----*/ /*----*/1)%20))/((abs(((I/10)-1)%20))+0.1)))* (((1- /*----*/ /*----*/ceiling((abs(I-1)%10)/((abs(I-1)%10)+.2)))+ /*----*/
19 Views
no comments
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Xml; using System.Runtime.Serialization; using System.Data.Linq; using System.Data.Linq.Mapping; using System.Linq.Expressions;
20 Views
no comments
declare @x int, @y int, @z int set @x = 1 set @y = 2 set @z = 1 -- returns @x (because not equal) select case when @x = @y then null else @x end -- returns null (because equal) select case when @x = @z then null else @x end
13 Views
no comments
'1/1/2000 1:30 AM' != '1/1/2000 1:31 AM' -- /// DECLARE @x datetime SET @x = GETDATE() SET @x = CONVERT(varchar, @x, 101) -- ///
14 Views
no comments
-- clean up any test artifacts if object_id('test1') is not null drop table test1 if object_id('test2') is not null drop table test2 if object_id('test') is not null drop view test GO -- the partition column must have a CHECK -- and be part of the PRIMARY KEY create table test1 (col1 int primary key check (col1 = 1), col2 varchar(50))
12 Views
no comments
<#@ template language="C#v3.5" hostspecific="True" debug="True" #> <#@ output extension="cs" #> <#@ assembly name="Microsoft.SqlServer.ConnectionInfo" #> <#@ assembly name="Microsoft.SqlServer.Smo" #> <#@ assembly name="System.Data" #> <#@ import namespace="Microsoft.SqlServer.Management.Smo" #> <#@ import namespace="Microsoft.SqlServer.Management.Common" #> <#@ import namespace="System.Data.SqlClient" #> <#@ import namespace="System.Collections.Specialized" #> <#
26 Views
no comments
select i.id AS IssueID, p.pname, ISNULL(c.cname,'') AS ComponentName, ISNULL(pv.vname,'') AS VersionName, pv.RELEASED AS Released, i.summary, i.DESCRIPTION, i.TIMEORIGINALESTIMATE/3600 AS HoursOriginalEstimate, i.TIMEESTIMATE/3600 as HoursEstimate,
23 Views
no comments
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) select convert(varchar(10),getdate(),121) CONVERT(VARCHAR,start_dttm,111)
11 Views
no comments
DECLARE @ParamFromDate datetime DECLARE @ParamToDate datetime DECLARE @ParamQueues varchar(50) DECLARE @CurrentDate DATETIME DECLARE @L_Start varchar(50) DECLARE @L_End varchar(50) DECLARE @LSQL as varchar(1500) DECLARE @LCOL as varchar(50) DECLARE @TableName1 varchar(50) DECLARE @TableName2 varchar(50)
14 Views
no comments
function global:out-zip($path){ $files = $input if (-not $path.EndsWith('.zip')) {$path += '.zip'} if (-not (test-path $path)) { set-content $path ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) } $zip=resolve-path($path) $ZipFile = (new-object -com shell.application).NameSpace( "$zip" )
203 Views
1 comments
CREATE TABLE table1 (id int); INSERT INTO table1 VALUES (1); INSERT INTO table1 VALUES (2); INSERT INTO table1 VALUES (3); CREATE TABLE table2 (id int); INSERT INTO table2 VALUES (2); INSERT INTO table2 VALUES (3); CREATE TABLE table3 (id int);
47 Views
2 comments
SELECT 'ALTER TABLE ' + TABLE_SCHEMA + '.[' + TABLE_NAME + '] DROP CONSTRAINT [' + CONSTRAINT_NAME + ']' FROM information_schema.table_constraints WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'
33 Views
no comments
SELECT table_name=sysobjects.name, column_name=syscolumns.name, datatype=systypes.name, length=syscolumns.length FROM sysobjects JOIN syscolumns ON sysobjects.id = syscolumns.id JOIN systypes ON syscolumns.xtype=systypes.xtype WHERE sysobjects.xtype='U' ORDER BY sysobjects.name,syscolumns.colid
19 Views
no comments
SELECT TOP {#} {Fields} FROM {table} ORDER BY newid()
22 Views
no comments
DECLARE @str nvarchar(128) SET @str = '[AdventureWorks].[dbo].[ErrorLog]' SELECT ISNULL(PARSENAME(@str, 4), @@SERVERNAME) AS [ServerName], ISNULL(PARSENAME(@str, 3), DB_NAME()) AS [DatabaseName], ISNULL(PARSENAME(@str, 2), ISNULL([default_schema_name], 'dbo')) AS [SchemaName], PARSENAME(@str, 1) AS [ObjectName] FROM [sys].[database_principals] WHERE [name] = SYSTEM_USER
41 Views
no comments
procedure TForm1.SearchButtonClick(Sender: TObject); var HurricaneName: string; begin HurricaneName := HurricaneSearchBox.text; with ADOQuery1 do begin Close; SQL.Text := 'SELECT * FROM Huracanes WHERE Huracanes.Nombre =' + tblname; Open; end;
26 Views
no comments
create table some_base_table ( batch_id int not null primary key clustered, batch_name varchar(250) not null, some_parm int null, some_parm2 int null ) insert some_base_table ( batch_id, batch_name, some_parm, some_parm2 ) values( 1, 'hello fred', 1, 2 ) insert some_base_table ( batch_id, batch_name, some_parm, some_parm2 )
34 Views
no comments
CREATE TABLE SomeBaseTable ( BatchId int NOT NULL PRIMARY KEY, BatchName varchar(250) NOT NULL, AnIntParameter int NULL, AnotherIntParameter int NULL ) GO INSERT INTO SomeBaseTable
115 Views
1 comments
// works as expected public wws_Item LoadBySku(string sku) { Expression< Func<wws_Item, bool> > func = itm => itm.Sku == sku; Entity = Context.wws_Items.Where(func).SingleOrDefault(); if (Entity != null) OnLoaded(Entity); return this.Entity;
172 Views
no comments
StockContext context = new StockContext(); User user = context.Users.Where( uss => uss.Pk == 1).SingleOrDefault(); Response.Write(user.FullName + "<br>"); user.FullName = user.FullName + "!"; StockContext context2 = new StockContext(); User user2 = context.Users.Where(uss => uss.Pk == 1).SingleOrDefault(); Response.Write(user2.FullName + "<br>"); user2.FullName = user2.FullName + "!";
78 Views
no comments
#!/bin/bash (while(true); do \ (mysql -e 'show innodb status \G' | grep undo\ log\ entries ; sleep 1 ; \ mysql -e 'show innodb status \G' | grep undo\ log\ entries ) | \ egrep '[0-9][0-9][0-9][0-9]' |awk '{print $10;}' ; done ) | \ perl -e '$t = ROWS_IN_TABLE; while(1) { \ $n ++; $nn; $a = <>; $b = <>; $nn += ($b-$a); \ printf "Rate: %d, avg: %d, %0.3f%% complete, done in %d sec\n", \ $b-$a, $nn/$n, ($b/$t)*100, ($t-$b)/($nn/$n); }';
41 Views
no comments
DECLARE @begin DATETIME DECLARE @end DATETIME SET @begin = '2009/09/17 00:00' SET @end = '2009/09/17 18:00' ; SELECT 'total count' = COUNT(1) FROM TB_TXN_REC WHERE CREATE_TIME_STAMP BETWEEN @begin AND @end ; SELECT 'avg response time(ms)' = AVG( DATEDIFF(MILLISECOND, CREATE_TIME_STAMP, UPDATE_TIME_STAMP) )
54 Views
no comments
param ( [string]$server = ".", [string]$instance = $(throw "a database name is required"), [string]$query ) $connection = new-object system.data.sqlclient.sqlconnection( ` "Data Source=$server;Initial Catalog=$instance;Integrated Security=SSPI;"); $adapter = new-object system.data.sqlclient.sqldataadapter ($query, $connection)
301 Views
2 comments
SELECT SERVERPROPERTY('BuildClrVersion') AS [BuildClrVersion] GO SELECT SERVERPROPERTY('Collation') AS [Collation] GO SELECT SERVERPROPERTY('CollationID') AS [CollationID] GO SELECT SERVERPROPERTY('ComparisonStyle') AS [ComparisonStyle] GO SELECT SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS [ComputerNamePhysicalNetBIOS] GO
119 Views
no comments
public IQueryable<Role> GetRolesByUserId(int userId) { var userRoles = from userRole in db.UserRoles where userRole.UserId == userId select userRole.RoleId; return from roles in db.Roles where userRoles.Contains(roles.RoleId) select roles; }
144 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
