SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Data is upload into txt files through job


Data is upload into txt files through job

Author
Message
arooj300
arooj300
Old Hand
Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)

Group: General Forum Members
Points: 301 Visits: 533
Hi All,

I have created stored procedure for checking the cpu usage and connection string.

----check the number of users---
EXEC sp_who2 'Active'

-----check the number of connection----
SELECT
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName
FROM
sys.sysprocesses
WHERE
dbid > 0

for above script I have created one job which will run every 1 hr and that information will be stored into the txt files through
job-properties-step-advanced-outfiles.

But the problem is the all the information is stored in one file.

actually what I want, for today when job will be started it will create one txt file and all the data will be stored in the same file and tomorrow again the job will start the samething happen.

So everyday I want to create new txt files and when the job will start the data will be stored in that file.

Is there any script or anyother solution, please share with me.

Thanks...

GROUP BY
dbid, loginame
Steve Jones
Steve Jones
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: Administrators
Points: 64941 Visits: 19118
You could use Powershell here. A job that calls this script and outputs to a filename based on the date.

There's a rename script here: http://ss64.com/ps/syntax-stampme.html

Here's a text file export: http://stackoverflow.com/questions/19686694/execute-sql-file-using-powershell-and-store-the-output-in-a-text-file

If you struggle with Powershell, then perhaps you can build a job that takes the current date and passes that to your export as the file name.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89149 Visits: 41143
arooj300 (3/3/2014)
Hi All,

I have created stored procedure for checking the cpu usage and connection string.

----check the number of users---
EXEC sp_who2 'Active'

-----check the number of connection----
SELECT
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName
FROM
sys.sysprocesses
WHERE
dbid > 0

for above script I have created one job which will run every 1 hr and that information will be stored into the txt files through
job-properties-step-advanced-outfiles.

But the problem is the all the information is stored in one file.

actually what I want, for today when job will be started it will create one txt file and all the data will be stored in the same file and tomorrow again the job will start the samething happen.

So everyday I want to create new txt files and when the job will start the data will be stored in that file.

Is there any script or anyother solution, please share with me.

Thanks...

GROUP BY
dbid, loginame


I just wouldn't do this. You're creating a nightmare for yourself when someone asks to see the data. Just store the data in a table reserved for DBAs and call it a day.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search