Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pmccann1
Posting Yak Master
107 Posts |
Posted - 2007-05-09 : 06:02:19
|
| i jave the following queryselect *,substring(stafflog,15,11) as test into #t1 from dbo.Customers where stafflog like '%armagh%'goselect left(stafflog,4) as Staff,count(left(stafflog,4)) as Total from #t1where cast(left(test,charindex(' ', test))as smalldatetime) = cast(convert(varchar(8),getdate()-1,1) as datetime)group by left(stafflog,4)goselect Title,Address1,Address2,Town,County,Postcode,TelephoneDay,TelephoneWork,TelephoneEvening,MobileTelephoneNo,Contact,Mail,Telephone,Terms,StaffLogfrom #t1where cast(left(test,charindex(' ', test))as smalldatetime) = cast(convert(varchar(8),getdate()-1,1) as datetime)godrop table #t1goi need this query to be scheduled to run at a certain time every day and the results to be put in a text file.is there an easy way to do this or what should i be looking at doing to get it to work |
|
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2007-05-09 : 06:08:45
|
| Set up a SQL Agent job to run on an appropriate schedule. Get it to execute a BCP (Bulk Copy Program) script to do the export to a text file. (Both of these can be looked up in BOL).I take it you're not in control of how this data is stored, as it looks like you're having to an awful lot of work to pull this out due to inapproriate data types, etc.Mark |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-09 : 06:09:03
|
| Read about job and bcp in sql server help fileMadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-09 : 06:10:40
|
MadhivananFailing to plan is Planning to fail |
 |
|
|
pmccann1
Posting Yak Master
107 Posts |
Posted - 2007-05-09 : 06:15:21
|
| cheers i will ahve a look at the bcp stuff in bol, i have inherited someone elses awful work prob is it holds 4 yrs worth. |
 |
|
|
pmccann1
Posting Yak Master
107 Posts |
Posted - 2007-05-09 : 07:09:34
|
| cheers i will ahve a look at the bcp stuff in bol, i have inherited someone elses awful work prob is it holds 4 yrs worth. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-05-09 : 07:12:36
|
you posted the same reply MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|