SQL Server 2005 CTE的用法
if object_id('[tb]') is not null
drop table [tb]
go
create table [tb]([id] int,[col1] varchar(8),[col2] int)
insert [tb]
select 1,'河北省',0 union all
select 2,'邢台市',1 union all
select 3,'石家庄市',1 union all
select 4,'张家口市',1 union all
select 5,'南宫',2 union all
select 6,'坝上',4 union all
select 7,'任县',2 union all
select 8,'清河',2 union all
select 9,'河南省',0 union all
select 10,'新乡市',9 union all
select 11,'aaa',10 union all
select 12,'bbb',10
;with t as(
select * from [tb] where col1='河北省' union all select a.* from [tb] a ,t where a.col2=t.id
)
select * from t
相关文档:
例子: int id = Convert.ToInt32(replace((Request.QueryString["id"]), ""));
public static string replace(string str, string str2)
{
str = str.Replace(";", str2);
str = ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
......
--查询现在日期,只要年月日
select convert(varchar(10),getDate(),120)
--查询现在日期,只要时分秒
select convert(varchar(8),getDate(),8)
Convert函数的一些说明,以下资料来源于网络
不带世纪数位 (yy)
带世纪数位 (yyyy)
标准
输入 ......
几道经典的SQL笔试题目(有答案)
(1)表名:购物信息
购物人 商品名称 数量
A 甲 2
B 乙 &n ......
SQLServer基本函数
1.字符串函数 :
字符操作类 :
upper(char_expr) 转为大写
lower(char_expr) 转为小写
UCase(string) 返回 Variant (String),其中包含转成大写的字符串。
LCase(string) 返回字符串的小写形式。
space(int_expr) 生成int_expr个空格
replicate(char_expr,int_expr) 复制字符串int_expr次
......