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

SQL递归查询部门

create function [dbo].[DeptTree](@initDeptCode  varchar(10))/*定义函数c_tree,输入参数为初始节点DeptCode*/
returns @t table(DeptCode varchar(10),UpDeptCode  varchar(10),lev int)/*定义表t用来存放取出的数据*/
begin
  declare @i int/*标志递归级别*/
  set @i=1
  insert @t select DeptCode,UpDeptCode,@i from vi_dept where DeptCode=@initDeptCode
  while @@rowcount<>0
  begin
  set @i=@i+1
  insert @t select a.DeptCode,a.UpDeptCode,@i from vi_dept as a,@t as b
 where b.DeptCode=a.UpDeptCode and b.lev=@i-1
  end
return
end
 select * from dbo.DeptTree('0000')


相关文档:

Sql Server基本函数

1.字符串函数
长度与分析用
datalength(Char_expr) 返回字符串包含字符数,但不包含后面的空格
substring(expression,start,length) 不多说了,取子串
right(char_expr,int_expr) 返回字符串右边int_expr个字符
字符操作类
upper(char_expr) 转为大写
lower(char_expr) 转为小写
space(int_expr) 生成int_expr个空格 ......

Sql函数大全

---返回表达式中指定字符的开始位置
select charindex('c','abcdefg',1)
---两个字符的值之差
select difference('bet','bit')
---字符最左侧指定数目
select left('abcdef',3)
---返回字符数
select len('abcdefg')
--转换为小字符
select lower('ABCDEFG')
--去左空格后
select ltrim('   &nbs ......

SQL分页语句

有关分页 SQL 的资料很多,有的使用存储过程,有的使用游标。本人不喜欢使用游标,我觉得它耗资、效率低;使用存储过程是个不错的选择,因为存储过程是经过预编译的,执行效率高,也更灵活。先看看单条 SQL 语句的分页 SQL 吧。
方法1:
适用于 SQL Server 2000/2005
SELECT TOP 页大小 *
from tab ......

用IP访问SQL Server 2008

1、开始->程序-->Microsoft SQL Server 2005>配置工具->SQL Server Configuration Manager->SQL Server 2005 网络配置 ->“xxx(您的数据库)”的协议,如下图
将“Named Pipes”和“TCP/IP”的状态调成“启用”,方法是在“Named Pipes”和“T ......

C#连接ACESS时,sql语句有错

在写sql语句时,一般都是一句解决,从来没想过说,把sql语句拆开来写。
例如下面这句:  string readstring = "select * from 实例 where 实例ID='"+eid+"'";
然后执行 Myconnection();
        DataSet ds = new DataSet();
        OleD ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号