Trending Up...

Trending Up...

get curr month start date, last month end date

declare @d datetimeset @d = 2009-05-05select dateadd(dd, -day(@d)+1, @d) as curr_mth_start, dateadd(dd, -day(@d), @d) as last_mth_end

2009-05-05 11:38:00

阅读数 464

评论数 0

get last date record of each product

use tempdbgoselect *into #tempfrom (select apple as product, 2008-10-02 as saledate, 87 as qtyunion all select apple, 2008-10-03, 34union all select ...

2009-02-04 20:22:00

阅读数 388

评论数 0

Calc open position

USE tempdbgoIF object_id([tb]) IS NOT NULL    DROP TABLE [tb]goCREATE TABLE [tb](    [id] int,    [amt] int)INSERT [tb]SELECT 1,       10UNION ALLSEL...

2008-12-23 10:33:00

阅读数 415

评论数 0

sql split path

 declare @str varchar(100)set @str = C:/data/test.csvdeclare @idx int, @len intset @len = len(@str)set @idx = @lenwhile(@idx > 0 and substring(@st...

2008-07-16 11:41:00

阅读数 438

评论数 0

SQL: select @var = xxx from table1 problem

 declare @var intset @var = 1print @var = + isnull(str(@var), null)select top 1 @var = [object_id] from sys.objects where 1=2-- @var != nullprint @v...

2008-07-16 11:33:00

阅读数 585

评论数 0

SQL Server 2005 error handling

Extract from : SQL Server Error Handling Workbenchhttp://www.simple-talk.com/sql/t-sql-programming/sql-server-error-handling-workbench/--Catch Error:...

2008-03-11 09:48:00

阅读数 550

评论数 0

Improve performance using hash keys

use CheckSum function to turn a string key to a hash key(integer), this will improve performance

2008-03-11 09:40:00

阅读数 410

评论数 0

Compare 2 string with case sensitive

Select * from test where convert(varbinary, column1) = convert(varbinary, ABCD)  

2008-03-11 09:35:00

阅读数 483

评论数 0

SQL read MS access(*.mdb)

select CustID, CustName from openrowset(Microsoft.Jet.OLEDB.4.0, C:/trade.mdb;Admin;, Customer)

2008-03-02 11:56:00

阅读数 464

评论数 0

SQL tree data struct(7): find the minimal cost route

-- find the minimal cost routecreate table flights(departure char(20), destination char(20), cost int)insert flights select Chicago, New York, 10 uni...

2008-03-02 11:54:00

阅读数 643

评论数 0

SQL tree data struct(5): AdjList2NestedSet

/*The organizational chart would look like this as a directed graph:            Albert (1,12)            /        /          /            /    Bert (...

2008-03-02 11:52:00

阅读数 736

评论数 0

SQL tree data struct(6): NestedSet2AdjList

declare @personnel table(emp varchar(30), lft int, rgt int)insert @personnelselect Albert, 1, 12union all select Bert, 2, 3 union all select Chuck, 4...

2008-03-02 11:52:00

阅读数 842

评论数 0

SQL tree data struct(4): AdjList2MatPath (for printing tree struct)

if object_id(proc_print_tree) is not null    drop procedure proc_print_treegocreate procedure proc_print_tree @raw_data_sql nvarchar(1000), @debug bi...

2008-03-02 11:51:00

阅读数 741

评论数 0

SQL tree data struct(3): nested set (1,12) include (2,3) & (4, 11) ...

-- Credit to JOE CELKO-- http://archives.postgresql.org/pgsql-sql/2001-11/msg00004.php--  CREATE TABLE Personnel --  (emp CHAR(10) NOT NULL PRIMARY K...

2008-03-02 11:49:00

阅读数 705

评论数 0

SQL tree data struct(2): materialized path (1.2.3...)

/*then materialized path representation of tree is easy to output: order by path, level*/declare @orgchart table (emp varchar(30), path varchar(100))...

2008-03-02 11:47:00

阅读数 819

评论数 0

SQL tree data struct(1): adjacency list (id, parentid)

declare @tree table(emp varchar(30), boss varchar(30))insert @treeselect Albert, NULLunion all select Bert, Albertunion all select Chuck, Albertunion...

2008-03-02 11:46:00

阅读数 540

评论数 0

clear sql server object by name

if object_id(clearobj) is not null drop proc clearobjgocreate proc clearobj @obj nvarchar(50), @debug int = 0with encryptionas    declare @sql nvarch...

2008-03-02 11:44:00

阅读数 436

评论数 0

SQL & Regex(4): usage

-- ========================================================================exec clearobj DFA_simulate, 1gocreate proc DFA_simulate    @str nvarchar(1...

2008-03-02 11:40:00

阅读数 475

评论数 0

SQL & Regex(3): subset construction

-- Subset Construction: convert NFA to DFA-- require: NFA_trans_table is filled with NFA state data-- ===============================================...

2008-03-02 11:39:00

阅读数 607

评论数 0

SQL & Regex(2): thompson construction

-- Thompson Construction : convert Regular Expression Parse Tree to NFA-- require: parse_node table is filled with tree-struct data-- ===============...

2008-03-02 11:38:00

阅读数 461

评论数 0

提示
确定要删除当前文章?
取消 删除
关闭
关闭