Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS package to update a table

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
I have table with fields like "ID" ,"name" ,"Amount" etc.
I need to UPDATE the Amount field for matching "Id" from an excel file which has the "id" and "amount" fields.
How can i write a DTS pcackage for the same ??
 
You will need to Connection one to Excell and one To SQL Server, then you can use Data pump to impot Excel to a temp table then update SQL from the Temp table. AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 
Thanks for ur help
Here is what i have done .
Imported data from xcel into a temp table and then used a stored procedure to update the main table from the temp table.
But the problem is that sometimes the the xcel data might be errorneous eg one of the columns is a date field ,if date is not in proper format then the DTS inserts a null into the temporary table.IS there any way that i can trap this error when the process is running ??
 
you could use the isdate() function to determine if it is a valid date or not if not you can either try to fix it or get the system date with getdate() AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 
Thanks for ur help
If the date is invalid i just need to skip the record and write it to and error log file or ELSE abort the whole process with an email being sent to concerned person to fix the bad date.Inserting system date in its place will not help.
Also i have a unique id field and in case this field contains a null or alphanumeric what can be done in that case??
 
Id fiels will drop your statment so you have to validate them prior to your insert and update, you could use isnull() on a where clause to make sure it is not null in case of an alphanumeric you could use isnumeric()as the example below:

where isnumeric(isnull(IdentCol, A))!= 0 AL Almeida
NT/DB Admin
"May all those that come behind us, find us faithfull"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top