-- 通过一个子级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 

 

 

相关文章:

  • 2022-12-23
  • 2021-08-28
  • 2021-07-13
  • 2021-06-17
  • 2022-12-23
  • 2021-12-26
  • 2021-11-11
猜你喜欢
  • 2021-04-05
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
相关资源
相似解决方案