Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-03-24 : 08:43:43
|
| Soha writes "Hi All,Please i have a problem with the insert command inside a user defined function.I'm using sql 2000 server.my function after simplification looks like this CREATE FUNCTION testInsert () RETURNS int AS BEGIN DECLARE @_i intset @_i=0 insert into temp_Table values (1,'value2 pla pla pla')return @_iENDwhere temp_Table is a table i have created on the Database,and i would like to fill it by this recursive function.but this simplified code gives me invalid use of insert within a function,But i'm in a case where i want to save record by record within a recursivly called function.Please is their any help or workaround??!!" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-03-24 : 08:47:19
|
| User defined functions cannot make permanent changes to a database. You'll need to rewrite this as a stored procedure. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-03-24 : 09:38:03
|
| you can use table variables, I believe, within a UDF but you cannot insert into an actual table .... can you rewrite your code to use table variables ?- Jeff |
 |
|
|
|
|
|