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
Windows Registry Editor Version 5.00
 
[HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\100\Tools\Shell\FontAndColors\{A27B4E24-A735-4D1D-B8E7-9716E1E3D8E0}]
"Colorable item format version"=dword:00000008
"Plain Text Foreground"=dword:00e0e0e0
"Plain Text Background"=dword:00303030
"Plain Text FontFlags"=dword:00000000
"Selected Text Foreground"=dword:00000000
"Selected Text Background"=dword:00c0c0c0
"Selected Text FontFlags"=dword:00000000
by Jon Erickson   June 30, 2010 @ 11:09am
30 Views
no comments
 
SQL
CREATE DATABASE dawnoises;
 
CREATE TABLE produse( 
    cod_produs number(10) not null primary key,
    cod_producator number(10) not null,
    denumire varchar(30),
    tip number(3) not null,
    cantitate number(8,2),
    um char(3),
    pret number(8,2)
by vlad tamas   June 01, 2010 @ 1:50am
29 Views
no comments
 
SQL
 GO
DBCC SHRINKFILE(DB_log, 1)
BACKUP LOG DDBWITH TRUNCATE_ONLY
DBCC SHRINKFILE(DB_log, 1)
GO 
by Petter Wigle   May 31, 2010 @ 12:58am
Tags: sql
29 Views
no comments
 
C#
private static bool AttemptInsertUniqueItem<T>(T item, Action<T> insert)
{
    bool success = false;
 
    try
    {
        insert(item);
        success = true;
    }
    catch (SqlException sqlEx)
by Jon Sagara   May 26, 2010 @ 11:20pm
40 Views
no comments
 
SQL
SELECT column_name , table_name
FROM information_schema.columns
order by table_name, column_name
by Nordin   May 12, 2010 @ 8:40pm
Tags: sql
22 Views
no comments
 
create proc a
as
select 1 as c1 , 'a' as a into #t
 
--select * from #t
exec bb 
go
 
 
by bnaya   May 09, 2010 @ 9:52pm
Tags: SQL
32 Views
no comments
 
XML
<roleManager enabled="true" defaultProvider="MySQLRole">
   <providers>
      <clear/>
      <add name="MySQLRole" 
           connectionStringName="MySQLConStr" 
           applicationName="/" 
           type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
   </providers>
</roleManager>
by SilverAdder   May 05, 2010 @ 12:40am
46 Views
no comments
 
XML
<membership defaultProvider="MySQLMembership">
   <providers>
      <clear/>
      <add name="MySQLMembership" 
           connectionStringName="MySQLConStr" 
           enablePasswordRetrieval="false" 
           enablePasswordReset="true" 
           requiresQuestionAndAnswer="true" 
           applicationName="/" 
           requiresUniqueEmail="false" 
by SilverAdder   May 05, 2010 @ 12:33am
57 Views
no comments
 
C#
public class SqlAppender : AppenderSkeleton
{
    private static readonly string CommandText = "INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)";
 
    public string ConnectionString { get; set; }
 
    protected override void Append(LoggingEvent loggingEvent)
    {
        using (var conn = new SqlConnection(ConnectionString))
        using (var cmd = new SqlCommand(CommandText, conn))
by Jon Sagara   April 25, 2010 @ 1:14am
48 Views
no comments
 
SQL
Set NoCount ON
 
Declare @tableName varchar(200)
 
set @tableName=''
 
While exists
 
(
by Unknown (google)   April 16, 2010 @ 12:00pm
43 Views
no comments
 
SQL
DECLARE @RandomNumber float
DECLARE @RandomInteger int
DECLARE @MaxValue int
DECLARE @MinValue int
 
SET @MaxValue = 4
SET @MinValue = 2
 
SELECT @RandomNumber = RAND()
by Jerry Nixon   April 12, 2010 @ 9:37am
Tags: TSQL, Random
64 Views
no comments
 
SQL
 
backup log <Database_Name, sysname, Database_Name> with truncate_only
go
use <Database_Name, sysname, Database_Name>
go
dbcc shrinkfile (<Database_Name, sysname, Database_Name>_log,  2)
go
 
DBCC SHRINKDATABASE(N'<Database_Name, sysname, Database_Name>' )
by Tareq Saleh   April 10, 2010 @ 2:03am
41 Views
no comments
 
SQL
-- Disable All constraint (FK)
EXECUTE sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT ALL"
GO
 
-- Enable
EXECUTE sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL"
GO
by Tareq Saleh   April 10, 2010 @ 1:33am
49 Views
no comments
 
SQL
set nocount on
 
-- build a working table called x
 
if (object_id('x') is not null) 
    drop table x
create table x (col1 varchar(50))
 
declare @sql nvarchar(500)
set @sql = 'insert into x select ''test'';'
by Jerry Nixon   April 09, 2010 @ 2:47pm
55 Views
1 comments
 
SQL
set nocount on
 
use tempdb
 
if (object_id('x') is not null)
    drop table x
create table x (id int primary key identity(1, 1), date datetime, value bigint, total bigint)
declare @x table(id int, date datetime, value bigint, total bigint)
 
declare @d datetime
by Jerry Nixon   April 08, 2010 @ 4:19pm
99 Views
no comments
 
SQL
-- sample table
 
create table [tb_Temp] ([Col1] varchar(10), [Col2] varchar(10))
 
-- sample data
 
GO
insert into [tb_Temp] values
     ('dog', 'brown')
    ,('dog', 'black')
by Jerry Nixon   April 02, 2010 @ 11:46am
Tags: SQL
73 Views
no comments
 
C#
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;
by Jerry Nixon   March 05, 2010 @ 9:36am
Tags: C#, LINQ, LINQ2SQL
360 Views
no comments
 
SQL
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
by Jerry Nixon   March 05, 2010 @ 9:11am
87 Views
no comments
 
SQL
'1/1/2000 1:30 AM' != '1/1/2000 1:31 AM'
 
-- ///
 
DECLARE @x datetime
SET @x = GETDATE()
SET @x = CONVERT(varchar, @x, 101)
 
-- ///
by Jerry Nixon   March 05, 2010 @ 8:53am
Tags: SQL, DateTime
115 Views
no comments
 
SQL
-- 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))
by Jerry Nixon   March 05, 2010 @ 8:47am
75 Views
no comments
 
C#
<#@ 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" #>
<#
by Rob   March 04, 2010 @ 7:47am
Tags: T4, Sql, c#
222 Views
no comments
 
SQL
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) 
select convert(varchar(10),getdate(),121)
CONVERT(VARCHAR,start_dttm,111)
by Stefan Sandström   February 23, 2010 @ 12:42am
Tags: sql, date
54 Views
no comments
 
SQL
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)
by Thom Lamb   February 12, 2010 @ 1:34pm
49 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" ) 
by Eric Hexter   January 17, 2010 @ 6:34pm
334 Views
1 comments
 
SQL
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);
by Luciano Evaristo Guerche (Gorše)   January 13, 2010 @ 9:54am
97 Views
2 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