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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Functions (Delete and Insert)

Author  Topic 

compound
Starting Member

7 Posts

Posted - 2006-06-16 : 14:21:51
Is There a way to use Delete or Insert statements within a function.
For example

CREATE FUNCTION Compl_Rating(@Accnt varchar(16))
RETURNS varchar(1000) AS
BEGIN
declare @result as varchar(1000)

insert Compl_Report (Account) values (@Accnt)

end

return @result

END

Thank you!

SreenivasBora
Posting Yak Master

164 Posts

Posted - 2006-06-16 : 16:44:54
You cannot manuplate data on Base tables from Function. Why cant you use Triggers / Stored Proc?


With Regards
BSR
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-19 : 05:09:36
Use Stored Procedure to do DML

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2006-06-19 : 05:27:16
what exactly are you trying to do? why do you need an insert inside the function?

--------------------
keeping it simple...
Go to Top of Page

gurusamy.senthil
Yak Posting Veteran

65 Posts

Posted - 2006-06-19 : 06:19:27
Don't make your DB complex.

As maddy said better go for Stored procedures to do your DML.
It is easier to use and handle errors in stored procedures
Go to Top of Page
   

- Advertisement -