How do i fix this code to work
Posted on 2011-03-01
I have this Stored Procedure I am writing, and i need to get the Database name from a table to run another query from that stored database name. how can i fix this.
declare cur1 cursor for
SELECT [id],[Source_Interid],[From_Vendor_ID],[To_Vendor_ID] FROM [CE_CUSTOM].[dbo].[dw_Vendor_Merge] Where processed_flag='N'
fetch next from cur1 into @id, @Company, @Old_Vendor_ID, @New_Vendor_ID
while @@FETCH_STATUS = 0
THIS IS THE PROBLEM LINE OF CODE.
-- Get the Vedors New Name
Select @New_Vendor_Name = select VENDNAME from @Company..pm00200 where VENDORID = @New_Vendor_ID
End line of code NOTE WHERE IT SAYS @COMPANY NAME THAT IS THE PROBLEM.
etch next from cur1 into @id, @Company, @Old_Vendor_ID, @New_Vendor_ID