I am trying to create an SSIS Package that sends out emails to different recipients and includes some of the data as a table that is either included in the body of the email or attached as an Excel file.
I have three tables, one that includes the email addresses, one that includes the error type and the main table that contains customer information like name, old address info, and new address info all broken out into about 16 different columns, of which are codes to pull from the two other tables to determine which person to email to update the address and a code description on why they need to update it.
I have created a script task to combine the data and pass it to a foreach loop container.
I'm not sure how to take the customer info, old address and new address columns of data from what I've pulled together in the sql task (CIF_Nbr to Current_XIPplus4) and create a table from it that can be inserted into the body or added as an attachment to the send mail task.
A branch could have multiple lines of data so I would prefer one attachment for all same branches sent only once to that branch.
My three tables have the following columns:
I'm using Microsoft Visual Studio 2008 and SQL server 2008 if that helps. I'm pretty much stuck with the default toolbox.
Hopefully this all makes sense. I'm fairly new to visual studio so the more detail the better. Thanks.
I decided to take this a different direction since this was being used on more of an adhoc basis.
Instead of SSIS I set it up in excel using power query to pull the data together from different sources and some vba code found at Ron Debruin's site http://www.rondebruin.nl/ to parse out and email each group needing to make an update.
Thanks to all for the help provided.
Let me know if you have any questions.
Related
Good day :-), I'm a beginner when it comes to asking questions here so please bear with me..
First, let me state the example problem at hand:
Company "A" has 4 branches, each placed in different provinces. Each branch, including the main company has an application that inputs a person's profile and saves it to SQL Server database. All data entered by the branching companies must be submitted to the main branch once in a month. But the main director doesn't want those data to be submitted via cloud, he wants it in a flash drive and one individual from each of those branches must travel to the main company, and submit the flash drive with the data inside.
Because if I just use backup & restore method, they will overwrite everything.
Thus, I have created a dummy database to hold those data. Same table, and each table column has the same data type as the original.
Using VB.NET how does one export the table of a database to a dummy database programmatically?
And once exported, how does one import it to the main company's database?
I'll be grateful if you provide me solutions or if you can point me out to the right direction. Also is my method correct?
You can import/export data from one server to another by using Linked Server.
we can do this also by using sql scripts for using simple select & insert query referring the "Servername.Database.tableName"
Now, if you need to do this in a timely manner, for example for every night you need to import/export the data, what i would suggest is to use Sql Agent. Here you can provide timing to execute the script such as date time and whether it is recursive etc...
with the script of import /export to targeted to specific server.
Ps:
Other approch would be to you use SSIS.
Hope this helps.
Thanks,
Satish
I want to link an invoice template in Excel to a SQL Server database.
The invoice currently contains only a few very basic fields like user/customer/date/item-id/description/quantity/Total etc.
In future more fields will be required.
What's the easiest way to store all that invoice data in realtime to a SQL Server database when the user presses enter in the invoice?
How many tables will I need to create in SQL Server?
The end users are not tech savvy at all, I need to deploy this solution without any technical requirements from them.
Thank you.
The best way to do this is to create an SSIS package that sucks up the excel spreadsheet and captures the data say once a day. The excel file will need to be in the same location, say a network folder and the structure will also have to be the same, meaning the columns and their names once setup will have to also be the same. Otherwise, it's best to have something like a web front end or a fat32 client (basically build an app in Visual Studio or something) that allows data input directory to the SQL server.
Check out this link to learn about it:
http://knowlton-group.com/using-ssis-to-export-data-to-excel/
I am a newbie in SQL so please bear with me. I am hoping you can help/guide me. I have a table on 5 MS SQL Servers that have identical Columns and I want to consolidate the data into a separate table/separate MS SQL Server.
the challenge is that I only have "Read Only Permission" from the source table (5 MS SQL Servers) but I have permission to create a table on the destination MS SQL Server DB.
another challenge is I wan to truncate or extract parts of the txt in one column of the source table and save them into different columns on the destination table.
Next challenge is for the destination table to query once a day the source table for any update.
See screenshot by clicking either of the URL.
Screenshot URL1
Screenshot URL2
Appreciate it very much if you can help/guide me. Many thanks in advance.
You'll need to setup a linked server and use either an SSIS package to pull the data into the form you need, or OPENROWSET/OPENQUERY queries with an insert on the server you do have write privileges.
Either pre-create a table to put the new data in, or if not needed build up a temporary table or the insert the data into a table variable.
To concat a field to a new field use something like the examples below:
SELECT (field1 + field 2) as Newfield
or
SELECT (SUBSTRING(field1, 2,2) + SUBSTRING(field2, 3,1)) as Newfield
Finally you should setup all this an agent Job scheduled to your needs.
Apologies if this is not as detailed as you like, but it seems there are many questions to be answered and not enough detail to help further.
Alternatively you could also do a lookup upon lookup (USING SSIS):
data flow task > download first table completely to destination server
JOIN TO
dataflow task > reading from destination server, do a lookup to 2 origin server (if match you might update, if not, insert)
repeat until all 5 of them are done.
This is NOT the most elegant or efficient solution, but it will definitely get the work done.
You'll have to forgive my ignorance on this - I'm generally a one server kind of guy!
I have a live and reporting server we'll call LIVE and REP.
I have a set of tables on LIVE, some data from which needs to be PIVOTted every night onto the REP server. This already happens through a SSIS package - trouble is - *the extract script is fixed but I need it to be dynamic.
ie. I need to have a new table on LIVE which defines what exactly is extracted to REP.
This means that I want to
DROP the extracted tables on REP every night
CREATE the new tables on REP as defined in the LIVE table
Build dynamic SQL to SELECT from the LIVE tables into the newly created REP tables
I'm concerned because I know SSIS can be funny about table definitions etc etc.
I'm not asking about how to build the dynamic SQL - I've already done that part, and it runs fine entirely on LIVE - but it needs to be cross-server.
Has anyone ever done this before? What is the best practice? Am I even allowed to EXEC dynamic SQL within a SSIS package, and can this be scheduled?
This might give you some ideas:
Create main workflow where you construct drop tables dynamically and create list of tables by creating a result set:
Setup a loop that iterates through each table in result set:
Then in your data flow task you can read from one connection / table and write to another:
What I need to do is some data between 2 databases. The source can be anything (comma separated file, xls file, any database, ...), the destination is MS SQL Server.
I do not need to sync all data, I just need to sync particular tables.
Example:
I need to sync accounting Software (runs on PostgreSQL) CUSTOMERS table with CRM (runs on SQL Server).
Some problems this tool should be able to face:
1) Accounting software customers table has 1 field that is not mapped in crm customers table. (In this way I want to map this extra field to the field CUSTOMERS_CUSTOM_DATA.EXTRA_FIELD)
2) Having some rules (like sync only customers whose code is between 10000 and 99999)
3) Allowing to perform some post insert tasks (for example I am using manually managed seuqences for the tanble IDs, so after inserting 10 records I need to add 10 to the sequence)
4) Having an exception handling mechanism so if something is wrong it can wither call a sql server stored procedure (that I already have and it will send an e-mail to me) or simply send a message to notify that something was wrong in the nightly sync.
5) Be easy to schedule when to perform data sync (hourly, daily, INCLUDING MANUAL)
6) Perform data conversion: if Surname field in source table is varchar(20) and in destination table is varchar(15) I want to explicitly say "perform a truncation".
7) Have different rules for insert or update. For example in the source e-mail field is not present, but I want to populate it in the destination I decide to perform this operation on insert only, not on update. (for example as I insert a new customer I want to populate the e-mail field concatenating name and surname, but then I want to let the users to modify it, this first insertion is just to simplify data entry, but then this particular case will be handled manually. So I want to say (on insert populate e-mail field, on update don't do anything with email field)
8) In case of delete in the source db don't delete on the destination but only change the varchar(10) STATUS to DELETED.
Note: I know that Integration Services will be perfect for this, but I must support the Express Edition, so SSIS is not an option.
I created a bunch of scripts and scheduled stored procedure that at present do what I need, but it is very hard to maintain and the total lack of a GUI makes the work much slower. I remember having seeing TALEND time ago, maybe that tool is also the answr I need, anyway I need to provide a quick answer to management, so I have now no time to investigate all the tools on the market, and I would prefer to have a suggestion from an expert.
I believe SQL Server Integration Services does all that, and I believe SQL Server Management Studio allows you to create and package your SSIS jobs so that they can be deployed elsewhere.
Finally I went for TALEND, I never really used SSIS, I just saw a live demo of it at a SQL Server conference. Anyway Talend is a free alternative (and quite rich) to SSIS, so it will suite the needs of all customers, including the ones (95%) that has SQL Server Express.