I can access tables in another database OK using the fully qualified name like
select * from [DEV-test].dbo.ArchiveCutoff
Now I want to do the same table in a stored procedure.
My code is
create procedure test
@src varchar (128)
as
begin
set @src = '[DEV-test]'
select * from @src.dbo.ArchiveCutoff
end
But I get an error:
Msg 102, Level 15, State 1, Line 12
Incorrect syntax near '.'.
What is the correct way to do this.