Solved

MSSQL Procedure

Posted on 2010-11-15
3
362 Views
Last Modified: 2012-05-10
Hello Experts!

I currently have a query which pulls user data...

Fname, lname, dob, userAcct

I also have an application that consumes that query, and writes the data to a text file (which is processed by a vendors application to create a user account in another SQL database (for realtime document management))

I want to skip the middle man by converting this query into  a stored procedure...  What I am unsure about, is once the query has been run, how can I write the retrieved rows straight to the other DB?  Crossing over to the other DB isn't the problem.  So if someone can show me how to write query results to a table, that would be great.


Thank you!

Fox
0
Comment
Question by:the_b1ackfox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34139461
Your original query
select Fname, lname, dob, userAcct
from tbl
where <some condition>

Open in new window

Insert directly to another db (on same server)
insert into otherdb..othertable(Fname, lname, dob, userAcct)
select Fname, lname, dob, userAcct
from tbl
where <some condition>

Open in new window

Insert directly to another db (on OTHER server/instance)
insert into otherserver.otherdb.dbo.othertable(Fname, lname, dob, userAcct)
select Fname, lname, dob, userAcct
from tbl
where <some condition>

Open in new window

0
 
LVL 9

Author Comment

by:the_b1ackfox
ID: 34139772
This looks like it will work great!   I can't wait to give it a whirl!  
0
 
LVL 9

Author Comment

by:the_b1ackfox
ID: 34142110
Cyberkiwi,  Awesome response.  I used the info to build a trigger.  total efficiency gained by this endeavor 35%.  Annoyance factor removed, my pain is gone.  Thank you, thank you
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Complex SQL Server WHERE CLause 9 40
Remove () 10 41
Using a SUBQUERY for the set variable 10 30
Query Task 8 23
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question