Solved

MSSQL Procedure

Posted on 2010-11-15
3
360 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
  • 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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

713 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