I have an msdb package to export data into a .csv file. It works well except every time i run this package it appends the data to .csv file. I need the .csv file to contain only new data, the old records has to be erased.
Any help on my request would greatly be appreciated. We are trying to maintain the growth of a particular table, by exporting and deleting data that is older then 90 days. Here are the 4 steps I need to do. I believe I know how to do 1 and 4;
1. Create a job that continously exports data that is older then 90 days to a text file
select *
from table A
WHERE (CREATED < DATEADD(DAY, - 90, GETDATE()))
(the column 'created' datatype is datetime and looks like this '3/5/2007 3:11:44 PM')
2. Have the job automatically name the exported file, the day it was exported (i.e. 07032007 (todays date))
3. Then zip that file (we're using 7-zip)
4. Then delete the data out of the table
delete
from table A
WHERE (CREATED < DATEADD(DAY, - 90, GETDATE()))
Im not a big scripter/coder, so I was wondering if there is anything I could do in SSIS. Im more familiar with DTS, so any kind of baby steps you could provide in SSIS, would go a long way.
What is the easiest way to accomplish this task with SSIS?
Basically I have a stored procedure that unions multiple queries between databases. I need to be able to export this to a text file on a daily basis and add a total records: row to the end of the text file.
I am using BCP to export a Table to a TAB delimited file. This works great, but in some fields a NULL in the Table is being exported as a character zero in the Tab file. I confirmed this by looking at the Tab file with a Hex editor.
I am trying to output data from my sql table to an excel spreadsheet and send it by email which works fine, the problem is he wants the date to be in the format d-mmm-yy, which is easy to format in excel manually, but he do not want to do this manually. I tried to do this when I select the date from the table to spreadsheet, "select convert(char,value_date,106) from table", but this don't get transported to the excel spreadsheet, I get my results on the spread sheet as dd/mm/yy. Can you please help either to set the date on excel forever to be in this format "d-mmm-yy" or to force this output to excel
Help!I have a table that has datetime format field, I exported the table toa csv while I dropped it and tried some other data, but now sqldoesn't recognise the date format for importing, heck I don't!The dates look something like:40:58.1Whick means nothing to me, or any of us here for that matter...Any ideas?John
I would like to export sql server 2005 tables to a text file using SSIS. It is easy to do this as a direct export. However, how could I separate the datetime field into two fields: one for date only and one for time only?
Hi, Basically the above is a very common requirement, please comment on my solution which I've arrived at by searching through the web; -
In summary I have used 3 SSIS components these are "Flat File Source", "Derived Column" and "SQL Server Destination".
1) File Connections Manager Editor 1.1) Within File Connections Manager Editor; - Name the data type e.g. "INTERCHANGE_NET_APP_DATE_SRC" and assign a type to the data type e.g. string[DT_STR]
1.2) Click on the Preview button to ensure the expected text is assigned to the expected data type.
2.4) Select "database timestamp [DT_DBTIMESTAMP] " as Data Type.
2.5) Within the Mappings tab of the SQL Destination Editor have; - Input Column as INTERCHANGE_NET_APP_DATE and Destination Column as INTERCHANGE_NET_APP_DATE.
Please comment on the above, I will then pass on my suggestion to Microsoft.
I asked this question below, but the answer was that the conversion will take place automatically, but I can't get that to happen. I have a flat file with an 8 position field that I identify as string (and I also tried date) that is yyyymmdd and it needs to go into the database field that is datetime format. IS there something I am doing wrong with the definition of it, or do I need to add some kind of conversion, and if so, what and how would that be done. I'm a dts Sql2000 expert, but the SSIS thing is driving me crazy. I have a ton of dts' to convert and the migration tool doesn't work because there are a lot of active X scripts in them. thanks for your help. Boston Rose
We have no certified SQL DBAs. Mainly because 95% of our production data is on Oracle and DB2 databases.
One of our Oracle DBAs is trying to write scripts that can be run by the AS400 robot to export data and backup the databases. I (being the only person with any SQL expierance) have been asked to ensure that the scripts she wrote will not only work but not bring down the server.
Can anyone point me to the correct place (web, book, ect) to find out how this is to be done? In years past my SQL servers have been stand alone dedicated units. With db backups scheduled through the SQL Manager and tape backups handled by the sysadmin.
I have created an package in SSIS and getting some problem when i am export date from OLEDB to Excel its format getting change. I am passing date format MM/dd/yyyy and its showing yyyy-MM-dd.
I have a ssis package where I need to have excel destination. In the Excel file, I need to have few rows with some text and then populate data below the text. One the text is like this:
Data as of: 08/25/2015
if the report ran today, then Data as of will have Yesterday. So, if the user opens that excel file after a week, then user should see same Data as of: 08/25/2015. not today()-day(1).
I was planing to handle on excel side with today()-day(1). but it only works the day it was run. Then the excel file is open after few days later, then it might as Data as of: 08/30/2015 which is not true. It should still stay Data as of:
08/25/2015 on what ever date the excel file is open. The SSIS package runs only once.
How do I handle this so that whenever user open the file, they will see Data as of: 08/25/2015. This is not a column in excel. It is like a description of data in excel.
Hello, I am using Visual Studio Web Developer 2005 Express Edition with MSSQL 2005. I need to import my db into the db in Godaddy.com web server. How do you know export MSSQL db in VSWD to csv file? I was trying Teratrax. But I am not sure how to browse for the database on my local machine.My local machine runs on XP Home Edition and I write my ASP.NET app with Visual Studio Web Developer Express Edition. How do I find out what my server name is so that I can connect to the database of my application? I don't think it is localhost because I don't have IIS running on my machine. From my understand VSWD has its own web server. But I am not sure how to connect to my data baswe so that I can export the database to CSV file using Teratrax.ThanksJacthemanus
Hi How can I export a MSSQL DB (table, SP, View, data) to a single csv file? I can export them to a sql file through Publishing Wizard, but how can I export it to a csv file? Thanks for help
Hi everybody, I am running DTS export data evry night, where my MyTable is being transformed into MyTable.txt. In my MyTable which sits in sql 7.0 I have a field which shows today's date as julian date ( today julian date is 109). Is there a way to write a procedure/trigger which will rename MyTable.txt on daily basis into MyTable109.txt for today; MyTable110.txt for tomorrow; etc... Kind of stuck with that.. Thanks alot, rudi
Hi, I am a novice with SQL script and I would like to know how can I make an export of my database in a flat file .txt after every new insert record on my database. Can anyone help me where I can find the code or else....I am very alone and I am out of the way.
I have a DTS package scheduled to run every day creates a text file on Server A and then moves the text file from Server A to Server B. But recently, the package is moving incomplete text file from Server A to Server B. Not every day. There is no problem in generating the text file.
So far, I verified the memory on Server B - No Probelms. Changed the package so it copies the text file from Server A to Sever B instead of moving, then delete the text file on Server B. - Didn't work out.
I am using BCP to output a table to a file. Is there a swich to say that you wish to output in chunks. My output file is 1gb, I wish to output in 100mb chunks. Unfortunately I do not know the structure of the data, otherwise I would have used select statement to limit the size of the output file.
I've created a dts package that exports data to an excel. The data exports okay, but I'd like to make a few changes on how the data is exported.
First, when the data exports to the excel file, it always creates a new excel sheet. How can I map the data to the existing sheet in the Excel file? I have an existing sheet named 'Sheet1'. I've deleted the other two sheets in the excel file, so there is only one sheet. When I created the destination table in the dts package for the data transformation task, I specified the name as 'Sheet1', but when it exports, it creates a new sheet named 'Sheet11'. I haven't been able to correct this.
Second, I'd like to either ammend data to the last row in the excel file, which I'd have to know the last record that was inserted from the SQL table. Or probably much easier, simply drop the existing sheet in the excel file and simply re-create and insert.
Using SQL 2005. Need to create fixed lenght text file from table. Was able to create the file, but all the data was in one big line. Selected fixed length with field names. How can I get my text file to have field names, fixed lenght with each record on it's only line. Thank you. David
Source: Meal_Time Connection manager "DestinationConnectionFlatFile" Description: The file name "\caguinc$ExportHousingExport.txt" specified in the connection was not valid. End Error Error:
I used same file for my local server(caguin) and it works fine. But when I run this package from computer other than caguin I got this error.
Dear all, i'm using sql server 2005. i've 20 queries to run. all the out put should come into excel file and each one to each sheet.is it possible?i've following the great aricle given below.but i didn't get the desired output.i used DTS import and export. it works fine but i need batch file for this. help me in this regard.
Hi all,i am having trouble trying to export this in xml. Basically inside anupdate trigger i need to export in xml or file the qty that has beenchanged. This then gets updated to another system. Is this a good idea? should i be using another table in between in case something happenson the other end?However, I tried something like this and it didn't recognize theselected table inside the bcp:CREATE TRIGGER [TRIGGER NAME] ON [fastpic].[FP_INVTRANS]FOR INSERT, UPDATEASDECLARE @selected varchar (100)IF NOT UPDATE(system_qty)BEGINRETURNENDDECLARE @cmd varchar(200)set @cmd = 'bcp "select system_qty, part_name from selected " queryoutc:parts.xml -S. -Usa -P -c -r -t'exec master ..xp_cmdshell @cmd 'IF someone could help or suggest something else i would appreciate it,than you
I need to export certain fields of a table from sql 2000 into a dbffile, but can't find the proper query command to make it work. I alsowant to set this up to run each night automatically.Any help will be greatly appreciated.Randy