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)
 Connect a function with a table

Author  Topic 

shwetaatul
Starting Member

5 Posts

Posted - 2012-03-30 : 04:31:15
I have a table

create table student_Records1 (ID int not null primary key, Name nvarchar(64),Maths int,Physics int,Total int)
And i inserted the below record in the table.
insert into student_Records1 values (1,'atul','','',''),(2,'rohit','','',''),(3,'manvendra','','',''),(4,'Vishal','','','')
Now, I created a below function and i want to insert the value of blank columns in the table through the function. Please help me in this.
CREATE FUNCTION Addition5()
RETURNS Decimal(6,2)
BEGIN
DECLARE @Total Int,
@Maths Int,
@Physics Int
Set @Maths=20
set @Physics=40
SET @Total = @Maths + @Physics
insert into Student_record1
RETURN @Total
END;
GO


Atul bhardwaj

rajarajan
Starting Member

48 Posts

Posted - 2012-03-30 : 04:59:20

Functions are computed values and cannot perform permanent environmental changed to SQL Server (i.e. no INSERT or UPDATE statements allowed).
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-30 : 17:57:30
you should be writing a procedure for above need

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

shwetaatul
Starting Member

5 Posts

Posted - 2012-03-31 : 02:53:22
Can you please provide me the stored procedure for this?

Atul bhardwaj
Go to Top of Page
   

- Advertisement -