>Hello
>
>I have a question.
>
>If I have something like this.
>
>CREATE PROCEDURE dbo.prueba151106
>@base varchar(20)
>AS
>select * from [CPSI-SERVER].[@base].[dbo].[certificados]
>GO
>
>SQL say " The name of the objet '@base.dbo.certificados' is no valid. "
>
>How can I do to that the store procedure can recive the name of the database
You can't use a variable as database name and/or server name and/or table name. If you want to pass any of these names as parameters you are forced to use so called dynamic SQL:
CREATE PROCEDURE dbo.prueba151106
@base varchar(20)
AS
BEGIN
DECLARE @cmd varchar(4000)
SET @cmd = 'select * from [CPSI-SERVER].['+@base+'].[dbo].[certificados]'
EXEC (@cmd)
END
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.