Monday, March 26, 2012

How can I put a newline within a string column?

I am using Derived Column Transformation Editor. I have 3 string values which I would like to combine them into one string and have a newline character inbetween the 3 strings. I cannot see a Char() function similar to TSQL to use for this purpose. I thought about creating a Variable but even to that I don't know how I can assign a newline character.

Any ideas?

here is a sample doing a carriage return and a line feed between a field and a static string. Should work between 2 fields as well assuming all the data type stuff meshes out.

Description + "\r\n" + " >>>>>>test"

search BOL for the topic Literals (SSIS) . The string literals at the bottom.
Keep in mind I do not think you will see these take 'effect' in a dataviewer but should see them in the destination such as a text file, or a common thing I have done is use property expressions of the message property on a SendMail task and use "\n" to create new lines in my email message. Here is a good gnarly sample of that....

"Rows Processed: \n NASDAQ: " + (dt_wstr,9)@.[nasdaqrawrows] + "\n NYSE: " + (dt_wstr,9)@.[nyserawrows] + "\n AMEX: " + (dt_wstr,9)@.[amexrawrows] + "\n \n ================== \n The Package: " + (dt_wstr,30)@.[PackageName] + "\n Started: " + (dt_wstr,25)@.StartTime + " \n Package Run Duration in Seconds: " + (DT_WSTR,10) (DATEDIFF( "ss", @.[System::StartTime] , GETDATE() ))

Hope that helps

|||Not required today, but for info, you can make good the lack of a CHAR function, as you can escape a uncicode character, as documented in the Literals BOL topic, but simply \xhhhh where xhhhh is the Unicode character in hexadecimal notation.|||I made a note of the request for CHAR, Darren. Thanks!sql

No comments:

Post a Comment