Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MSSQL Procedure

Posted on 2010-11-15
3
Medium Priority
?
384 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
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.

927 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