SQL上如何按日期调用值

我有这个SQL查询。

在下面的查询中, 今天将设置第一部分插入物中的随机数据之一, 明天从底部随机插入数据。 这将继续这样。如何编写此查询?

select * from #tempAccessCode
declare @accessCode int=  ( select accessCode from #tempAccessCode)
declare @prefix int=  ( select prefix from #tempAccessCode)

------------------------------------------------
create table #TempPrefix(AccessCode nvarchar(max),Prefix nvarchar(max))


insert into #TempPrefix values ('1671','6710')
insert into #TempPrefix values ('1670','6700')                                   
insert into #TempPrefix values ('1669','6690')
insert into #TempPrefix values ('1668','6680')
insert into #TempPrefix values ('1667','6670')
insert into #TempPrefix values ('1666','6660')
insert into #TempPrefix values ('1665','6650')
insert into #TempPrefix values ('1664','6640')
insert into #TempPrefix values ('1663','6630')
insert into #TempPrefix values ('1662','6620')
----------------------------------------------
insert into #TempPrefix values ('1661','6610')
insert into #TempPrefix values ('1660','6600') 
insert into #TempPrefix values ('1659','6590')
insert into #TempPrefix values ('1658','6580')
insert into #TempPrefix values ('1657','6570')
insert into #TempPrefix values ('1656','6560')
insert into #TempPrefix values ('1655','6550')
insert into #TempPrefix values ('1654','6540')
insert into #TempPrefix values ('1653','6530')
insert into #TempPrefix values ('1652','6520')

declare @AccessCodee nvarchar(max)
declare @prefixx nvarchar(max)

Select top 1 @prefixx = Prefix,@AccessCodee=AccessCode  from #TempPrefix order by  newid()

Select @prefixx,@AccessCodee

drop table #TempPrefix
-------------------------------------------------

update  [CallList]  set AccessCode = @AccessCodee , Prefix = @prefixx 
where  CampaignId  =5409 and ListId=@listId
评论