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 2008 Forums
 Transact-SQL (2008)
 Given Function is Correct or not

Author  Topic 

itnagaraj
Yak Posting Veteran

70 Posts

Posted - 2011-02-07 : 02:36:46
I am passing one parameter and return single value.But below function throw error.

Create FUNCTION [dbo].[UDF_GetTransTypeFormat]
(
@TranTypeId int
)
RETURNS @TransFormat Varchar
AS
BEGIN
Select Tran_Type_Format into TransFormat From MASTER_TRAN_TYPE
Where Tran_Msg_Type='I' And Tran_Type_Id=@TranTypeId
return @TransFormat
END

For example.i am passing a parameter value=25 it return aaaaaaaa

where i can change it.

V.NAGARAJAN

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-07 : 02:56:30
do you mean it is returning incorrect value? or any specific error? post the error!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-02-07 : 03:13:40
"SELECT INTO" in a function? Yikes.
Try this
CREATE FUNCTION dbo.UDF_GetTransTypeFormat
(
@TranTypeID INT
)
RETURNS VARCHAR(20)
AS
BEGIN
RETURN (
SELECT Tran_Type_Format
From MASTER_TRAN_TYPE
Where Tran_Msg_Type = 'I'
AND Tran_Type_Id = @TranTypeId
)
END



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -