We are rewriting a foxpro database to SQL. I encountered the following scenario. Foxpro can create two cursors with the same name under two different if statements.
I tried to do the same in SQL. Created two temporary tables. Something like below:
IF @id = 1
BEGIN
SELECT * INTO #abc from table1
END
IF @id = 2
BEGIN
SELECT * INTO #abc frm table2
END
NEXT here I write a code to update the values of a temporary table column with another column. But sql throws me an error saying ‘there is already an object named #abc in the database’.
Can I please have a solution to this?
Thank you.
For your specific use case given that both have the same structure you could use.
to avoid the parser issue you are encountering. I agree with Ben’s comment though that a literal translation of the FoxPro code is likely going to lead you with an inefficient and unmaintainable mess.