ed2_d2
ed2_d2

Reputation: 1

scalar function in select

I'm trying to use a function to strip anything but numeric characters from a column in a select statement. I'm getting the error that the multi-part identifier could not be bound on the line calling the function.

Here is my function

    create function scrubNetWt (@input varchar(50))
    returns varchar(50)
    AS
    Begin
        Return Left(
             SubString(@input, PatIndex('%[0-9.-]%', @input), 8000), 
             PatIndex('%[^0-9.-]%', SubString(@input, PatIndex('%[0-9.-]%', @input), 8000) + 'X')-1)
    End

Here is my select statement where I'm trying to use the function

    USE [TFP]
    GO

    SELECT [pick_ticket_id]
          ,[pick_ticket_no]
          ,[proform_net_wt] 
          ,[proform_cr_no]
          ,[TFP].[dbo].[scrubNetWt(proform_net_wt)] AS net_wt
    FROM [TFP].[dbo].[pick_ticket_ud]

Upvotes: 0

Views: 48

Answers (1)

Juan Carlos Oropeza
Juan Carlos Oropeza

Reputation: 48187

Try

[TFP].[dbo].[scrubNetWt] (proform_net_wt)

Upvotes: 1

Related Questions