易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

调用SQL函数来实现汉字模糊查询

在sql中创建用户自定义拼音函数:
create function f_GetPy(@Str nvarchar(400))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert @t select '吖','A' union all select '八','B'
union all select '嚓 ......

SQL Server和MySQL中Top用法的区别

      今天练习在JSP页面中实现分页效果,在查询语句方面牵扯到了top的用法。简要做一下总结:
      为实现类似top的功能,我们在SQL Server中和MySQL中使用到的SQL语句是不同的。
      1、在SQL Server中,我们使用  select top N * ......

(网摘)SQL分页语句


之前偶然逛网页的时候看到的,详细的网址忘记copy过来了,真是抱歉。觉得简单易懂,所以转了,嘻嘻
有关分页 SQL 的资料很多,有的使用存储过程,有的使用游标。本人不喜欢使用游标,我觉得它耗资、效率低;使用存储过程是个不错的选择,因为存储过程是经过预编译的,执行效率高,也更灵活。先看看单条 SQL 语句的分页 SQL ......

sql server 2005 image数据类型的使用

       最近做一个项目的时候需要往数据库内插入图片,上网查了一下,主要有两种方法,第一就是在数据库中存储图片的路径,然后在程序中根据读取的路径读取图片;这种方法简单、容易使用,但是在图片过多时不好管理。
      第二种就是将图片转换成二进制存储于数 ......

常用sql相关

1修改基本表
 添加列 alter table tableName add<新列名><数据类型>[完整性约束]
 删除列 alter table tableName drop<新列名><数据类型>[完整性约束]
2创建
  建表create table tableName(
id primary key AUTO_INCREMENT(mysql);
id primary key identity(1,1)(s ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号