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
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it needs to be an function, but how do i select random rows without using rowcount?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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