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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:27:50+00:00 2026-06-06T13:27:50+00:00

I came across this situation while migrating our DB from Foxpro to SQL. Below

  • 0

I came across this situation while migrating our DB from Foxpro to SQL.

Below is the sample scenario.. (My original code is little complicated so just tried to create my own example)

I created several table variables in my sql server function to get what I require.

DECLARE @temp_1 TABLE(ID INT,
Name NCHAR(7),
bday DATE,
m_status NVARCHAR(10)); 

INSERT INTO @temp_1
SELECT Name, bday, m_status from Employee_Info


DECLARE @temp_2 TABLE(ID INT,
City NCHAR(7),
Country NVARCHAR(10),
zip NVARCHAR(10)); 

INSERT INTO @temp_2
SELECT City, Country, zip from Employee_Address

Next comes a situation where I need to use one each of the fields from the above table variables to derive data into my third table variable.

For example,

DECLARE @temp_full TABLE (
Name NCHAR(7),
City NCHAR(7));

INSERT INTO @temp_full
SELECT @temp_1.Name, @temp_2.City FROM @temp_1, @temp_2 WHERE @temp_1.ID = @temp_2.ID

[EDITED TO INCLUDE INSERT USING JOINS]

INSERT INTO @temp_full
SELECT @temp_1.Name, @temp_2.City FROM @temp_1 INNER JOIN @temp_2 ON @temp_1.ID = @temp_2.ID

However, when I do @temp_1.Name, @temp_2.City I get an error saying I must delcare the scalar variable @temp_1, @temp_2.

Can anyone please tell me how to resolve this problem.

Thank you for your help.

  • 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-06T13:27:52+00:00Added an answer on June 6, 2026 at 1:27 pm

    This is not foxpro and @variable_tables are not cursors like in foxpro, there are no any current record pointer for table, tables are sets of records and you must work with it as with sets.

    If you need to fill @temp_full with records combined from tables @temp_1 and @temp_2, you must use select with joining this two tables like this:

    INSERT INTO @temp_full
    SELECT 
        temp_1.Name, 
        temp_2.City 
    FROM @temp_1 temp_1 
    JOIN @temp_2 temp_2 on temp_2.ID = temp_1.ID
    

    Also note that you must use alias for variable tables

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

Sidebar

Related Questions

I came across a code like below: #define SOME_VALUE 0xFEDCBA9876543210ULL This SOME_VALUE is assigned
Came across this question: explain the role of dominators in reverse engineering Java code.
I came across this question from interviewstreet.com Machines have once again attacked the kingdom
I came across this code. class SomeClass::OtherClass : public BaseClass { // stuff in
I came across this code construct in Linux and would like to understand it
I came across this in some JS code I was working on: if (
working with a team of more traditional developers we came across this situation: We
I came across this very odd situation, and i thought i would throw it
I came across with this situation. I have one already developed Application in 2.0,
I came across this kind of situation but could not resolve, any hint would

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.