referencing a table of different database

Hi all:

I have two databases, principal and cuentas in two servers

In a sp of principal I reference a table in cuentas I do

cuentas.dbo.paises

In my local server it works fine, but not in my hosting. I don't know what the difference is. This hosting is 1and1. Maybe I have to do something in order to reference another database on the same server. I asked the hosting but the didn't answer me yet.

In a post I read that they have to allow reference different databases on same server. Is is true?

November 30th, 2013 10:24am

What the error throwing at host?
Free Windows Admin Tool Kit Click here and download it now
November 30th, 2013 11:01am

Hi:

Thanks

The error is Invalid object name 'cuentas.dbo.paises'.

The sp is

USE [Cresolia]
GO
/****** Object:  StoredProcedure [dbo].[seleccionar_tarifas]    Script Date: 30/11/2013 18:18:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[seleccionar_tarifas]
	(
	@idioma tinyint,
	@obra tinyint=0,
	@p0 int
	)
AS
	set nocount on
	declare @iva smallmoney
	select @iva=iva from cuentas.dbo.paises where p0=(select r1 from cuentas.dbo.regiones where r0=(select campo0 from dbo.varios where v0=12))
	if @idioma=1 select campo0,obra_espanol as obra,dbo.importe(0,@p0,publico1*(1+@iva/100),0) as publico1,dbo.importe(0,@p0,publico2*(1+@iva/100),0) as publico2,dbo.importe(0,@p0,privado1*(1+@iva/100),0) as privado1,dbo.importe(0,@p0,privado2*(1+@iva/100),0) as privado2,dbo.importe(0,@p0,convert(float,replace((select campo0 from dbo.varios where v0=2244+tp1),',','.')),0) as comision from dbo.[tarifas publicaciones] inner join dbo.obras on o0=tp1 cross join dbo.varios where v0=11 and o0=case when @obra>0 then @obra else o0 end
	else if @idioma=2 select campo0,obra_ingles as obra,dbo.importe(0,@p0,publico1*(1+@iva/100),0) as publico1,dbo.importe(0,@p0,publico2*(1+@iva/100),0) as publico2,dbo.importe(0,@p0,privado1*(1+@iva/100),0) as privado1,dbo.importe(0,@p0,privado2*(1+@iva/100),0) as privado2,dbo.importe(0,@p0,convert(float,replace((select campo0 from dbo.varios where v0=2244+tp1),',','.')),0) as comision from dbo.[tarifas publicaciones] inner join dbo.obras on o0=tp1 cross join dbo.varios where v0=11 and o0=case when @obra>0 then @obra else o0 end
	     else if @idioma=3 select campo0,obra_frances as obra,dbo.importe(0,@p0,publico1*(1+@iva/100),0) as publico1,dbo.importe(0,@p0,publico2*(1+@iva/100),0) as publico2,dbo.importe(0,@p0,privado1*(1+@iva/100),0) as privado1,dbo.importe(0,@p0,privado2*(1+@iva/100),0) as privado2,dbo.importe(0,@p0,convert(float,replace((select campo0 from dbo.varios where v0=2244+tp1),',','.')),0) as comision from dbo.[tarifas publicaciones] inner join dbo.obras on o0=tp1 cross join dbo.varios where v0=11 and o0=case when @obra>0 then @obra else o0 end
		      else select campo0,obra_portugues as obra,dbo.importe(0,@p0,publico1*(1+@iva/100),0) as publico1,dbo.importe(0,@p0,publico2*(1+@iva/100),0) as publico2,dbo.importe(0,@p0,privado1*(1+@iva/100),0) as privado1,dbo.importe(0,@p0,privado2*(1+@iva/100),0) as privado2,dbo.importe(0,@p0,convert(float,replace((select campo0 from dbo.varios where v0=2244+tp1),',','.')),0) as comision from dbo.[tarifas publicaciones] inner join dbo.obras on o0=tp1 cross join dbo.varios where v0=11 and o0=case when @obra>0 then @obra else o0 end

As u see I reference cuentas.dbo.paises. Cuentas is another database I have in same instance in local machine. In hosting, because the 2 databases are in different servers, I may have to do something, bu don't know what to do

Thanks a lot

November 30th, 2013 12:30pm

Sounds like it might be a permissions problem.

Could it be that the user that you are working with has permission to only one database?

Check that it is set as owner of both databases.

Free Windows Admin Tool Kit Click here and download it now
November 30th, 2013 10:15pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics