Solved

MSSQL Procedure

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now