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 8578897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:29:51+00:00 2026-06-11T20:29:51+00:00

I have the following table: RecordID Name Col1 Col2 …. ColN The RecordID is

  • 0

I have the following table:

RecordID 
Name
Col1
Col2
....
ColN

The RecordID is BIGINT PRIMARY KEY CLUSTERED IDENTITY(1,1) and RecordID and Name are initialized. The other columns are NULLs.

I have a function which returns information about the other columns by Name.

To initialized my table I use the following algorithm:

  1. Create a LOOP
  2. Get a row, select its Name value
  3. Execute the function using the selected name, and store its result
    in temp variables
  4. Insert the temp variables in the table
  5. Move to the next record

Is there a way to do this without looping?

  • 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-11T20:29:52+00:00Added an answer on June 11, 2026 at 8:29 pm

    Cross apply was basically built for this

    SELECT D.deptid, D.deptname, D.deptmgrid
        ,ST.empid, ST.empname, ST.mgrid
    FROM Departments AS D
        CROSS APPLY fn_getsubtree(D.deptmgrid) AS ST;
    

    Using APPLY

    UPDATE some_table
    SET some_row = another_row,
        some_row2 = another_row/2
    FROM some_table st
      CROSS APPLY
        (SELECT TOP 1 another_row FROM another_table at WHERE at.shared_id=st.shared_id)
    WHERE ...
    

    using cross apply in an update statement

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

Sidebar

Related Questions

I have the following table ( simplified ): RecordID bigint IDENTITY ItemID bigint ConfigID
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
Imagine I have following table: NAME DATE OTHER_CONTANT 'A' '2012-06-05' 'baz' 'A' '2012-06-04' 'bar'
I have the following table drop table names; create table names( name varchar(200), surname
I have the following table RecordID Group Date Value ---------------------------------------- 1 Test 1 1/01/2012
I have the following table recordID createdDate ForeignKeyID 00QA000000PtFXaMAN 2012-01-03 13:23:36.000 001A000000ngM21IAE 00QA000000OS2QiMAL 2011-12-15
I have following table structure table domains ID | name | ________________________ 1 |
I have following table schema - CREATE TABLE [dbo].[TEST_TABLE] ( [TEST_TABLE_ID] [int] IDENTITY(1,1) NOT
I have following table structure ID Name Parent_ID 1 abc 0 2 efg 1
I have the following table schema: RecordId EmpID AbsCode DateFrom DateTo --------------------------------------------------------------- 666542 1511

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.