-- 通过一个子级ID 返回一级分类名称
alter function calcclass
(@dclassid as int)
returns varchar(50)
as
begin
-- 通过一个子级ID 返回一级分类名称
-- 返回ID 和父级分类ID 直到父级分类ID=0
declare @cid int
declare @cfatherid int
set @cid=@dclassid
while (@cid>0)
select @cfatherid=cid,@cid=cfatherid from trd_archivesclass where cid=@cid
return (select cname from trd_archivesclass where cid=@cfatherid)
end

如果需要在 Sql Server 中批量插入日期,可采用以下语句:

DECLARE @i int
SET @i = 0
WHILE @i < 365
BEGIN
INSERT INTO table1
( Day1 ,Flag2 ,AddTime3 )
VALUES ( DATEADD(DAY,@i,'2015-1-1') ,1,GETDATE() )
SET @i = @i + 1
END

最新文章

  1. (利用tempdata判断action是直接被访问还是重定向访问)防止微信活动中用户绕过关注公众号的环节
  2. 《Qt Quick 4小时入门》学习笔记
  3. hdu2094 set初体验
  4. memcached(二)事件模型源码分析
  5. rpyc 回调模式工作不正常
  6. 在Ubuntu 12.04安装和设置Samba实现网上邻居共享
  7. PHP Array函数分类
  8. const与define的异同
  9. Introduction to neural network —— 该“神经网络” 下拉“祭坛”
  10. maven添加本地依赖包方法
  11. 实现基本TCP套接字客户端
  12. 蓝桥杯-隔行变色-java
  13. Java图形界面学习---------简易登录界面
  14. antlr v4 使用指南连载2——准备环境
  15. 解决 spring-cloud-starter-zipkin 启动错误
  16. json的xpath:简易数据查询
  17. windows7安装dlib过程中遇到的问题总结以及运行实例效果
  18. java标志性接口
  19. 微信小程序wxml無法實現頁面跳轉的問題
  20. (转载)intellj idea 如何设置类头注释和方法注释

热门文章

  1. JVM学习笔记(一,待整理)
  2. Action向视图传值的6种方式(转)
  3. innodb存储引擎之内存
  4. BZOJ 1003 最短路dp
  5. 不使用C库函数(Sprintf)将void* 指针转换为十六进制字符串
  6. target runtime com.genuitec.runtime.genuitec.jee60 is not defined
  7. linux编译esp8266
  8. [Algorithm] Finding Prime numbers - Sieve of Eratosthenes
  9. 钉钉报警-prometheus-alertmanager
  10. 前端基础教程-jQuery EasyUI 的EasyLoader实例