Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Passing variables into a SProc

Author  Topic 

Shrews14
Starting Member

37 Posts

Posted - 2007-01-17 : 06:38:02
Hi everybody,

If anybody could help me with this i would love to hear from you, at the moment this is driving me crazy.

Now i have a stored procedure in SQL server 2000, which i need to pass some variables into (pretty straight forward so far!!) I am copying tables from one database to another and i what to be able to choose the spefic database i'm copying to, this is the basic's of my query!

CREATE PROC sp_Copy_Facility
@FacilityID int,

/* Select and append Data tables */

-SELECT testDB.dbo.dt_test.* INTO
-******.dbo.dt_sample
-FROM testDB.dbo.dt_test
-WHERE testDB.dbo.dt_test.Facility_ID = @FacilityID
-option (keep plan)

i have also tried this:

CREATE PROC sp_Copy_Facility
@FacilityID int,
@DBIN nvarchar(40),
@DBOUT nvarchar(40)
AS

DECLARE @SQLString varchar(1000)
DECLARE @S2 nvarchar(1000)

/* Select and append Data tables */

SET @SQLString = 'SELECT ' + @DBIN +'.dbo.dt_test.* INTO '
SET @SQLString = @SQLString + @DBOUT + '.dbo.dt_test
SET @SQLString = @SQLString + 'FROM ' + @DBIN + ' .dbo.dt_test WHERE ' + @DBIN + '.dbo.dt_test.Facility_ID = @FacilityID option (keep plan)'

please help i need to get this done and i posted this on a number of different web sites with as yet no joy!!

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-17 : 06:44:56
DUPLICATE POST! DO NOT CROSS POST!
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=77686


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Shrews14
Starting Member

37 Posts

Posted - 2007-01-17 : 06:50:56
Sorry many thanks for the reply, really needed to get this done.
Go to Top of Page
   

- Advertisement -