Hi guys!
I want to set database as parameter so that when you select a data you chooos with database to use, I keep getting the same error, my stored procedure is as follows(runned successfully):
>>>>.
Create procedure proc_TestingDatabases
@databasename varchar (30)
,@tablename varchar (30)
as
execute
('use' + @databasename + 'select * from' + @tablename)
>>>>>>>>>>
but on the application I receive an error saying incorrect systxt near (*).
Then I tested the following one from the book:
>>>>>>>>>>
DECLARE @databasename varchar(30), @tablename varchar(30)
SET @databasename = 'Northwind'
SET @tablename = 'Products'
EXECUTE
('USE' + @databasename + 'SELECT * FROM' + @tablename)
>>>>>>>>>>>>
I receive the same error, but the they have a result as follows:
ProductName
Chai
Chang
Anniseed Syrup
Is the book lying or there is something that I do wrong.
Thanks
johannes johannesPosted Apr 14, 2006, 6:44 AM
The main thing is that I want to copy a table from one database and move it to another, so I have to select a table and database and to which database I will move it to. If that work, then I will try to create a table at run time (the user must be able to do that) but specify the table name, then it will be added on the select statement with the database