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 2005 Forums
 Transact-SQL (2005)
 Cannot find either column "dbo" or the user-defin

Author  Topic 

rammohan
Posting Yak Master

212 Posts

Posted - 2008-10-17 : 10:10:38
Hi, I have created a Scaler valued function and I am trying to use it in a Stored Proc. Everything was fine, My SP created sucessfully. But when I execute that SP, get this error-

Cannot find either column "dbo" or the user-defined function or aggregate "dbo.Split", or the name is ambiguous.

Function Code-

USE [Accounts]
CREATE FUNCTION [dbo].[Spilt]
( @Array VARCHAR(1000),
@separator VARCHAR(10),
@number INT
)
RETURNS VARCHAR(100)
AS
BEGIN
DECLARE @parseValue VARCHAR(100)
DECLARE @RetValue VARCHAR(100)

DECLARE @separator_position INT
DECLARE @array_value VARCHAR(1000)
SET @array = @array +@separator

DECLARE @Num INT;

SET @Num =len(replace(isnull(@Array, ''), @separator, @separator + ' ')) - len(isnull(@Array, '')) +
case when ltrim(isnull(@Array, '')) <> '' then 1 else 0 end

WHILE patindex('%' + @separator + '%' , @array) <> 0
BEGIN
SELECT @separator_position = patindex('%' + @separator + '%', @array)
SELECT @array_value = left(@array, @separator_position - 1)
SET @parseValue= Cast(@array_value AS varchar)
SELECT @array = stuff(@array, 1, @separator_position, '')

IF(@Num = @number)
SET @RetValue = @parseValue;--REVERSE(@parseValue);
SET @Num = @Num-1;
END
RETURN @RetValue

END

Procedure

CREATE PROC [dbo].[ax_InsertTransaction]
(@VID INT,
@LedgerIDs VARCHAR(1000),
@Amounts VARCHAR(1000),
@TransType VARCHAR(500)
)
AS
declare @index int
declare @separator char(1)
set @separator = ',';
DECLARE @LID INT
SET @LID =0;
DECLARE @Amount money
set @Amount =cast(0 as money);
DECLARE @TT CHAR(1)
SET @TT = ' ';
DECLARE @COUNT INT;
SET @COUNT = len(replace(isnull(@LedgerIDs, ''), @separator, @separator + ' ')) - len(isnull(@LedgerIDs, '')) +
case when ltrim(isnull(@LedgerIDs, '')) <> '' then 1 else 0 end

BEGIN
while ( @COUNT >=1)
BEGIN
SET @LID = CAST([dbo].[Split](@LedgerIDs,',',@COUNT) AS INT)

SET @Amount = cast([dbo].[Split](@LedgerIDs,',',@COUNT) AS MONEY)

SET @TT = cast([dbo].[Split](@LedgerIDs,',',@COUNT) AS CHAR(1))

INSERT INTO Transactions (VID, LID,Amount, TransType, Status, CreatedOn)
VALUES (@VID, @LID,@Amount,@TT,'true',getdate())

SET @COUNT = @COUNT-1;
END

END



Any helps appreciated....

One can never consent to creep,when one feels an impulse to soar
RAMMOHAN

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-17 : 10:13:35
Are you executing them together? if yes put a GO seperating the UDF and SP body
Go to Top of Page
   

- Advertisement -