I'm having trouble using a user defined variable to tell a select statement inside my proc what database it is supposed to be selecting from. Here is the code.
-----------------------------------------------------------
alter PROCEDURE moveimg
(@olddb char(12),
@newdb char(12))
as
select
b.imgid as imgid,
(select sum(datalength(img)) from @olddb.dbo.imgs a where a.imgid <= b.imgid) as total,
c.objidref
into imgsplit
from
imp00001.dbo.imgs b,
choctawkrs.dbo.imglinks c
where
b.imgid=c.imgidref
-----------------------------------------------------------
alter PROCEDURE moveimg
(@olddb char(12),
@newdb char(12))
as
select
b.imgid as imgid,
(select sum(datalength(img)) from @olddb.dbo.imgs a where a.imgid <= b.imgid) as total,
c.objidref
into imgsplit
from
imp00001.dbo.imgs b,
choctawkrs.dbo.imglinks c
where
b.imgid=c.imgidref