August 11, 2008 at 5:00 pm
Hi,
Request your help with this.
The table RACCRUALDETAIL contains several records for each PERSONNUM. I need to run this query once for each PERSONNUM and store the results(comma separated) to a text file each time. If there are no results, there should still be a row which contains the amount as 0.
SELECT ACCRUALCODENAME, EFFECTIVEDATE, AMOUNT, PERSONNUM
FROM RACCRUALDETAIL
WHERE
(PERSONNUM = '990031084')
AND ((ACCRUALCODENAME = 'Vacation') )
AND (TYPE = 11)
AND EFFECTIVEDATE =
(
select max(EFFECTIVEDATE) FROM VP_RACCRUALDETAIL
WHERE (PERSONNUM = '990031084')
AND ((ACCRUALCODENAME = 'Vacation') )
AND (TYPE = 11)
)
Thanks,
Krish.
August 11, 2008 at 5:43 pm
Hi Krish,
have a look at SSIS - very easy to do it using that
I'm a DBA.
I'm not paid to solve problems. I'm paid to prevent them.
August 11, 2008 at 7:21 pm
Hi Krish
If you are not familair with SSIS, you can use BCP to export query results to a csv file. I would recommend to have a script containing your sql query and run that script using BCP. you can run BCP from cmd.exe or can use xp_cmdshell. But you must familiarise yourself with security issues related to using xp_cmdshell.
you can find more details about BCP at http://msdn.microsoft.com/en-us/library/ms162802.aspx
Cheers
Anam
August 11, 2008 at 8:20 pm
Another option is SQLCMD.
example
sqlcmd -S "servername" -Q "some query" -o \\Output_location\outputfile.txt
there are plenty other options.
-- Cory
August 12, 2008 at 12:07 pm
Just use Import EXport wizard.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply