Solved

MSSQL Procedure

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

635 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