Thanks for the quick response. It was my mistake. Its SQL 2000 and not SQL 2005. Any way to get this one on SQL 2000.
Main Topics
Browse All TopicsI'm trying to schedule a daily job to pull out specific data from a table that gets added every night. I accessed Jobs icon under SQL server agent and proceeded to creating a job using 'new job'.
A new table gets created with the name prathab_table_date (Name changed due to security reasons.) I would like to pull out data matching the domain name (domain name is a field in this particular table) 'xxx' and I go onto define what other fields I would like to see along with that. In the properties window, I went to steps tab and here is what my command looks like.
SELECT field A, field B, field C, field D, domainname
FROM prathab_table
WHERE (DOMAINNAME = 'xxx')
On this very window, I selected the type to be transact-SQL script (TSQL). There are quite a few options to choose from such as operating system command (CmdExec) DTS, replication distributor, etc.
While my query works, there are couple of things it wont do for me. Where exactly do I define what type of report I would like, for example, a CSV file, excel file, word doc. Secondly, since my table gets added the date with the table name prathab_table_todaysdate, how can I define this so that that day's date will get appended to the query, before its run.
We dont necessarily have to use transact SQL, as long as it works, I'm ok with any mechanism.
Thanks for your help in advance.
PK
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
It works about the same way, but with DTS...
http://msdn2.microsoft.com
http://www.devguru.com/fea
Thanks Chapman. I was able to create the DTS part and have it talk to the right database. However, my query isn't quite working right. With the information given above under description, would you be able to tell me what the query should look like. I want to be able to pull out a few other fields along with it, when the domainname matches the string xxx.
Thanks,
PK
Let's make this easy. The following query works fine. It creates the excel output.
CREATE TABLE `Results` (
`TIMSTAMP` DateTime ,
`USERNAME` VarChar (255) ,
`WorkstationName` VarChar (255) ,
`COMPUTERNAME` VarChar (255) ,
`Info` VarChar (255),
`domainname` VarChar (255)
)
What I want it to do is to be able to pull out the TIMSTAMP, USERNAME, WorkstationName, ComputerName, Info, only when the Domainname field matches the string XXX. For that to happen, I changed it to the following.
CREATE TABLE `Results` (
`TIMSTAMP` DateTime ,
`USERNAME` VarChar (255) ,
`WorkstationName` VarChar (255) ,
`COMPUTERNAME` VarChar (255) ,
`Info` VarChar (255),
(DOMAINNAME VarChar CHECK (DOMAINNAME =XXX))
)
Is this the right way of doing it to begin with?
Thanks in advance
The above query wont work since the results isn't table that exists in the database. Its a table I created as part of the DTS query. Since it doesn't exist otherwise, it errors out saying unable to find objects 'results'.
However they way we can get this to work would be, a new table gets created everyday in the database with a timestamp attached to it. The name of the table is prathap_table_200803160000
I was thinking we can attach the timestamp to the query you had created. For example, in the query below, timestamp should be the date for that particular day added to the table name. While the first part of the name doesn't change which is prathab_table, the second part of the name changes with the date. Its in this format prathap_table_200803160000
SELECT *
FROM `prathab_table(timestamp)`
As I said earlier, this query below works fine, no need to mess with the timestamp,. I'm justnot able to throw in the condition. There are three different entries for domainname and they are lets say xxx, yyy, zzz. I only want the data when the domain name is xxx. It cant be too hard, It has to be pretty easy. Per the instruction, there is a check constraint that goes with the create table command. I have no idea why it wont. The connections are fine. If I remove the check command, the query works perfectly and Im able to get the report I want. Only thing I m having difficulty with this is the condition.
CREATE TABLE `Results` (
`TIMSTAMP` DateTime ,
`USERNAME` VarChar (255) ,
`WorkstationName` VarChar (255) ,
`COMPUTERNAME` VarChar (255) ,
`Info` VarChar (255),
`domainname` VarChar (255)
)
This will be really easy if there is a another mode of communication. It seems I'm not describing the problem (simply because I m really not SQL guy just doing someone else's job) right and I'm pretty sure it will only take a minute for you to get this to work. Is there another way we can communicate?
Business Accounts
Answer for Membership
by: chapmandewPosted on 2008-03-17 at 11:43:37ID: 21144886
You're going to have to create an SSIS package to export the data to a file, then schedule that package to run every so often.....
com.com/da tacenter/? p=205
http://blogs.techrepublic.