If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Creating Stored procedures

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-12-03, 05:40
iamwisey iamwisey is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
Creating Stored procedures

HI

I am trying to create a stored procedure which inputs data from an access db to an SQL DB. My code:

CREATE PROCEDURE s2_comms
@DBpath varchar(50)
AS
EXEC sp_addlinkedserver 'TempS2commsServer', 'Access 97', 'Microsoft.Jet.OLEDB.4.0', @DBpath
CREATE DATABASE S2comms
USE S2comms
select * into Codes from OPENQUERY(TempS2commsServer, 'SELECT * FROM Codes')
select * into comms from OPENQUERY(TempS2commsServer, 'SELECT * FROM comms')
EXEC sp_dropserver 'TempS2commsServer'

But it tells me:
a USE database statement is not allowed in a procedure or trigger.

i am new to sql and cant figure out how to get round this, any ideas?
thanks for any help.
Reply With Quote
  #2 (permalink)  
Old 10-30-03, 15:28
mkkmg mkkmg is offline
Registered User
 
Join Date: Oct 2003
Location: Dallas
Posts: 76
....

well if you are using SQL Server, just create a DTS package to do this, much easier. Then you can schedule it to run when ever.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On