rafaelrgl
asked on
insert does not work with newid()
hi, can someone make this query works,
insert int @table1(id)
set rowcount 1
select t1.id from tb_test
order by newid()
that's any simply example of my quer. but if we do the syntax for this one i can do on mine.
insert int @table1(id)
set rowcount 1
select t1.id from tb_test
order by newid()
that's any simply example of my quer. but if we do the syntax for this one i can do on mine.
ASKER
i am trying to put this inside an function, but it does not execute, shows an error saying:
invalid use of a side-effecting operator 'SET ROW COUNT' whithin a function .
invalid use of a side-effecting operator 'newid' within a function.
:(
invalid use of a side-effecting operator 'SET ROW COUNT' whithin a function .
invalid use of a side-effecting operator 'newid' within a function.
:(
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
it needs to be an function, but how do i select random rows without using rowcount?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
set rowcount 1
insert into @table1(id)
select t1.id from tb_test t1
order by newid()
not real sure what you are trying to do though