Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8563295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:55:43+00:00 2026-06-11T16:55:43+00:00

I have a situation where I’m parsing a varchar value to extract numbers, and

  • 0

I have a situation where I’m parsing a varchar value to extract numbers, and I have to update my table to put the numeric value into a new field in my table. I have encapsulated the string parsing into a stored proc. Now I’m trying to write the update statement.

MY table looks like this (simplified to show only the key values):

CREATE TABLE dbo.oper_pacer
(
oper_pacer_id                 int         NOT NULL,
oper_pacer_fluroscopy         varchar(20) NULL,
oper_pacer_fluoro_min         float       NULL
)

My function takes a varchar(20) value and returns a float, doing the parsing and conversion of the number:

CREATE FUNCTION usf_ParseFluoro( 
@parm1 VARCHAR(20)
)
RETURNS FLOAT
AS
BEGIN
    DECLARE @value VARCHAR(20)
    DECLARE @midVal VARCHAR(20)
    DECLARE @nPos INT
    DECLARE @lPos INT

SELECT @midVal = SUBSTRING(@parm1, PATINDEX('%[0-9]%', @parm1), PATINDEX('%[0-9]%',@parm1) + LEN(@parm1)+1)

SELECT @value = 
    (CASE 
        WHEN PATINDEX('%[a-z]%', @midVal) = 0
            THEN @midVal
        ELSE RTRIM(SUBSTRING(@midVal, 1, PATINDEX('%[a-z]%', @midVal)-1))
    END)

    RETURN CONVERT(FLOAT, @value)
END

Here’s my problem:

How do I write the update of my original table, to loop through, calling the function, and putting the return value into oper_pacer_fluoro_min, given that there’s no way to do a for each loop in T-SQL?

EDIT:
Once I created the function, the Update was pretty simple, with a little trial and error: I needed to put in the dbo. prefix to the function to get it to run with my current DB permissions:

UPDATE oper_pacer SET oper_pacer_fluoro_min = dbo.usf_ParseFluoro(oper_pacer_fluroscopy)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:55:44+00:00Added an answer on June 11, 2026 at 4:55 pm

    I don’t think you can do it using a procedure. I solved a similar problem using a function, and I think it would work for you as well. You may need to restructure your table (even if it’s in a temporary table), so that you’ll have all of the necessary data elements available to the function. But once you do that, your UPDATE statment is just the function call on the input field.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation where I need to change the order of the columns/adding new
I have situation to extend the Enumerable class in c# to add the new
I have a situation to choose between parsing XML documents in Oracle PL/SQL and
I have situation where i have column in mysql table from which i populate
I have situation, when click on button opens the new browser window with search
Situation: Have a SET field called country with values ('us','uk','fr','intl') When I go to
I have situation where I am mapping table's columns to the primary key of
I have situation where I want to extract multiple values from multiple source objects
I have situation where table is created dynamically,i don't know the table name it
i have situation like this: class IData { virtual void get() = 0; virtual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.