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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trigger with rtrim

Author  Topic 

lonil
Starting Member

4 Posts

Posted - 2008-02-01 : 05:04:04
Hi!

I want to put a trigger on insert (bulk insert). It´s supposed to do RTRIM and LTRIM on the incoming data to a specific column in a table. The data comes from a textfile.

What to do? Totally stuck..

Thankful for all help!

//lonil

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-01 : 08:07:01
Why are you using trigger for this? Cant you use transform data task in SSIS for this? How are you transfering data now?
Go to Top of Page

lonil
Starting Member

4 Posts

Posted - 2008-02-01 : 09:09:44
Hi!

Because of difficulties while accessing my tables from SSIS I instead chose to import my data using BULK INSERT in a query.
Problem: One of the columns in the text-file needs to let all its data go through a RTRIM-function before its loaded into the table-column.
So.... I thaught... maybe a trigger would do the trick. A trigger activated on INSERT that would send the data through RTRIM() and then put in its right place in the table.

Is this possible?

What to do? Still totally stuck..

//Lonil



quote:
Originally posted by visakh16

Why are you using trigger for this? Cant you use transform data task in SSIS for this? How are you transfering data now?

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-01 : 09:35:50
quote:
Originally posted by lonil

Hi!

Because of difficulties while accessing my tables from SSIS I instead chose to import my data using BULK INSERT in a query.
Problem: One of the columns in the text-file needs to let all its data go through a RTRIM-function before its loaded into the table-column.
So.... I thaught... maybe a trigger would do the trick. A trigger activated on INSERT that would send the data through RTRIM() and then put in its right place in the table.

Is this possible?

What to do? Still totally stuck..

//Lonil



quote:
Originally posted by visakh16

Why are you using trigger for this? Cant you use transform data task in SSIS for this? How are you transfering data now?




You might have to compromise a lot on performance if you are going for trigger.
Go to Top of Page

lonil
Starting Member

4 Posts

Posted - 2008-02-01 : 09:38:43
So... what would you suggest?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-01 : 09:43:25
i suggest you do it via SSIS. I didnt totally understand the difficulty of accessing tables in SSIS though.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-01 : 09:59:19
Just came across this link. Just refer to FORMATFILE portion seems like thats what you want:-

http://msdn2.microsoft.com/en-us/library/ms188365.aspx
Go to Top of Page

lonil
Starting Member

4 Posts

Posted - 2008-02-01 : 10:40:23
Thank you for your time and your will to help me.
Problem remains though.. Its not the file that needs formating - its a column in a table in a file.
I need to pick that particular information and RTRIM it before inserting in my database table. well well. Weekend soon.. Maybe a rest from it is what i need.
//Lonil


quote:
Originally posted by visakh16

Just came across this link. Just refer to FORMATFILE portion seems like thats what you want:-

http://msdn2.microsoft.com/en-us/library/ms188365.aspx

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-01 : 10:45:26
quote:
Originally posted by lonil

Thank you for your time and your will to help me.
Problem remains though.. Its not the file that needs formating - its a column in a table in a file.
I need to pick that particular information and RTRIM it before inserting in my database table. well well. Weekend soon.. Maybe a rest from it is what i need.
//Lonil


quote:
Originally posted by visakh16

Just came across this link. Just refer to FORMATFILE portion seems like thats what you want:-

http://msdn2.microsoft.com/en-us/library/ms188365.aspx





they are discussing the same thing there i guess. What they tell is you need to create a format file and give its refference while doing BULK INSERTION to perform custom formatting (in this case ltrim(rtrim())...). You will specify formatting you require inside ie i guess (havent tried this yet!)
Go to Top of Page
   

- Advertisement -