第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

不知道各位大俠還有其他的什么好方法能實現(xiàn)嗎?

不知道各位大俠還有其他的什么好方法能實現(xiàn)嗎?

慕妹3146593 2022-10-20 15:15:58
大家好,我有一個數(shù)據(jù)表(如表1所示),我想對每個站在開始時間和結(jié)束時間之間插入時間段,步長為1天,得到的結(jié)果應(yīng)該為表2所示,表1結(jié)構(gòu)如下站名 開始時間 結(jié)束時間s1 1980-1-1 1980-2-1s2 1992-2-1 1993-3-1表2站名 時間s1 1980-1-1s1 1980-1-2s1 1980-1-3................s1 1980-2-1s2 1992-2-1s2 1992-2-2..........s2 1993-3-1我自己編了一個表函數(shù),但是調(diào)用函數(shù)時怎么才能把各個站點的參數(shù)傳遞到函數(shù)里呢?謝謝各位大俠了--@tminit是開始時間,@tmend是結(jié)束時間,TM是時間CREATE FUNCTION CaculateDailyTM(@STCD char(8),@tminit datetime,@tmend datetime)returns @mytbl table (STCD char(8),TM datetime)asbegindeclare @temptm datetimeset @temptm=@tminitwhile @temptm<=@tmendbegininsert into @mytbl select STCD,@temptmset @temptm=@temptm+1endreturnRETURNendGO
查看完整描述

2 回答

?
一只斗牛犬

TA貢獻1784條經(jīng)驗 獲得超2個贊

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1

有問題HI我

這個問題用標(biāo)致函數(shù)比較難,1樓調(diào)用標(biāo)致函數(shù)的方法也是錯誤的,正確的方法應(yīng)該是:
SELECT * FROM DBO.CaculateDailyTM()

我用游標(biāo)實現(xiàn) ,比較好理解:

create table tb1(zm char(8),sd datetime,ed datetime)
GO
insert into tb1 values('s1','1980-1-1','1980-2-1')
insert into tb1 values('s2','1992-2-1','1993-3-1')
GO
--建立測試數(shù)據(jù)

declare zm_cursor cursor fast_forward for select zm from tb1
declare @t1 datetime,@t2 datetime,@zm char(8)
declare @tb table(zm char(8),d datetime)
open zm_cursor
fetch next from zm_cursor into @zm
while @@fetch_status=0
begin
select @t1=sd,@t2=ed from tb1 where zm=@zm
while @t1<=@t2
begin
insert into @tb values(@zm,@t1)
set @t1=dateadd(day,1,@t1)
end
fetch next from zm_cursor into @zm
end
select * from @tb
close zm_cursor
deallocate zm_cursor

GO

DROP TABLE TB1


查看完整回答
反對 回復(fù) 2022-10-24
?
紅顏莎娜

TA貢獻1842條經(jīng)驗 獲得超13個贊

select dbo.CaculateDailyTM(站名, 開始時間,結(jié)束時間) from 表1

查看完整回答
反對 回復(fù) 2022-10-24
  • 2 回答
  • 0 關(guān)注
  • 111 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號