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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:51:52+00:00 2026-05-22T22:51:52+00:00

I have to create a Procedure with dynamic SQL and generate the Update Statements.

  • 0

I have to create a Procedure with dynamic SQL and generate the Update Statements.

I have tables

Col.TMap.T_Mp

 ID   M_Type  ID_F     SF1      SF2
  1   Acc     ACC_ID   AC_ID    NULL
  1   STA     STA_ID   ST_ID    NULL
  1   CHa     Cha_ID   CH_ID    NULL

ACC

ID    AC_ID   SV1   SV2     SO1    SO2
1     12      6     NULL    =      NULL

STA

ID     STA_ID      SV1     SV2      SO1    SO2
1      1           Open    NULL     =      NULL
1      2           CLosed  NULL     =      NULL

CHa

ID    CHa_ID    SV1    SV2    SO1    SO2
1     1         PH     NULL   =      NULL
1     2         EM     NULL   =      NULL

I need to update Ms.AT.AT_CRAW_Dmtemp table with ACC_ID,STA_ID and CHA_ID from the above tables:

The out put should be:

UPDATE  mt 
SET ACC_ID = ac.ACC_ID
FROM Ms.AT.AT_CRAW t
INNER JOIN Acc ac ON t.AC_ID=SV1
AND ac.ID = 1
INNER JOIN Ms.AT.AT_CRAW_Dmtemp mt 
ON mt.[SRID] = t.[RID]



UPDATE  mt 
SET STA_ID = ac.STA_ID
FROM Ms.AT.AT_CRAW t
INNER JOIN STA ac ON t.ST_ID=SV1
AND ac.ID = 1
INNER JOIN Ms.AT.AT_CRAW_Dmtemp mt 
ON mt.[SRID] = t.[RID]



UPDATE  mt 
SET CHa_ID = ac.CHa_ID
FROM Ms.AT.AT_CRAW t
INNER JOIN CHa ac ON t.CH_ID=SV1
AND ac.ID = 1
INNER JOIN Ms.AT.AT_CRAW_Dmtemp mt  
ON mt.[SRID] = t.[RID]

So can anyone suggest me on how to do this?

  • 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-05-22T22:51:52+00:00Added an answer on May 22, 2026 at 10:51 pm
    select
    'UPDATE  mt
    SET ' + ID_F + ' = ac.' + ID_F + '
    FROM Ms.AT.AT_CRAW t
    INNER JOIN ' + M_Type + ' ac ON t.' + SF1 + '=SV1
    AND ac.ID = 1
    INNER JOIN Ms.AT.AT_CRAW_Dmtemp mt 
    ON mt.[SRID] = t.[RID]' as SQL
    from Col.TMap.T_Mp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Stored Procedure which executes some dynamic SQL. I want to use
I have a stored procedure that looks like: CREATE PROCEDURE dbo.usp_TestFilter @AdditionalFilter BIT =
Suppose I have a stored procedure that manages its own transaction CREATE PROCEDURE theProc
I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) ,
This is what I currently have: CREATE OR REPLACE TRIGGER MYTRIGGER AFTER INSERT ON
I have to create a dialog based application, instead of old CFormView type of
I have to create a site definition for a client that must contain pre-defined
I have to create the sin function from scratch in my Comp Sci class,
i have to create an asp.net page dynamically on runtime. It should work like
Is it possible to create/have a non-modal .net OpenFileDialog I have a UI element

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.