insert into table_A(f1, f2)
select
B.f1,
RAND(DATEPART(ms, GETDATE()))
from
table_B B
但老是提示“Invalid use of 'getdate' within a function.”
...全文
9210打赏收藏
一个函数的问题。
我想在一个函数内往一个表中的一列中INSERT进随机数 insert into table_A(f1, f2) select B.f1, RAND(DATEPART(ms, GETDATE())) from table_B B 但老是提示“Invalid use of 'getdate' within a function.”
--取得新编号的函数
create function f_nid(@head char(2))
returns char(14)
as
Begin
declare @dt DateTime
select @dt=@dt from v_getdate
insert into table_A(f1, f2)
select
B.f1,
RAND(DATEPART(ms, @dt))
from
table_B B
end
go