B
Bill Schanks
I have this stored proc:
Create PROCEDURE dbo.spoc_ev_update_branch_cds (
@dbName varchar(25))
AS
-- ===============================================================
-- Procedure: spoc_ev_update_branch_cds
-- Written By: xxxxxxxxxxxxxxxxxxxxxxxxxx
-- Purpose: Deletes all records from Branch Table,
-- and updates with new values.
--
-- Updates from @dbName
-- Date Developer Description
-- ------- ----------------- -------------------
-- 03/08/2006 Bill Schanks Initial version
-- ===============================================================
begin
Set nocount on
/* Delete old records */
DELETE FROM t_BranchCodes
/* Bring in new records */
INSERT INTO dbo.t_BranchCodes (Branch_Cd, Branch_Nm)
SELECT Branch_Cd, Branch_Nm FROM (e-mail address removed)
end
GO
However I can't seem to use variables in the FROM Clause. Select and
Where are fine. Is there a workaround for this? I am getting a syntax
error.
I could create all the SQL in the Front end adp, but I would prefer to
do it via sp. Any ideas?
Note: This is pulling from a linked server, and works just fine if I
hard code the dbname. The reason I want this to be a variable is
because the linked server is a data wharehouse and we have 16+
Database's (Each are a snapshot of the End of Month Data on our
MainFrame)
Create PROCEDURE dbo.spoc_ev_update_branch_cds (
@dbName varchar(25))
AS
-- ===============================================================
-- Procedure: spoc_ev_update_branch_cds
-- Written By: xxxxxxxxxxxxxxxxxxxxxxxxxx
-- Purpose: Deletes all records from Branch Table,
-- and updates with new values.
--
-- Updates from @dbName
-- Date Developer Description
-- ------- ----------------- -------------------
-- 03/08/2006 Bill Schanks Initial version
-- ===============================================================
begin
Set nocount on
/* Delete old records */
DELETE FROM t_BranchCodes
/* Bring in new records */
INSERT INTO dbo.t_BranchCodes (Branch_Cd, Branch_Nm)
SELECT Branch_Cd, Branch_Nm FROM (e-mail address removed)
end
GO
However I can't seem to use variables in the FROM Clause. Select and
Where are fine. Is there a workaround for this? I am getting a syntax
error.
I could create all the SQL in the Front end adp, but I would prefer to
do it via sp. Any ideas?
Note: This is pulling from a linked server, and works just fine if I
hard code the dbname. The reason I want this to be a variable is
because the linked server is a data wharehouse and we have 16+
Database's (Each are a snapshot of the End of Month Data on our
MainFrame)