Import multi-line address field into Salesforce using DBAmp - import

Addresses in Salesforce are a structured compound data type. As such, different fields exist for the street, city, state, and country. The street field is a single field. How does one import multi-line street addresses such as:
1 Street Line
2 Street Line
3 Street Line
City, State, 12345
Country
using DBAmp?

The key is to embed newline characters \n in the field value with the T-SQL char() function. Thus, the solution is:
address1 + char(10) + address2 [+ char(10) + addressN ]

Well, have you run into any trouble?
On Account the BillingStreet / ShippingStreet is a textarea field. Meaning good old newline character \n should do just fine, as long as the total length < 255.
Map the remaining address components to BillingState etc and you're good to go?
Sorry if the answer is a bit generic but as stupid as it sounds - try it out on few acconts before full import and you should get the hang of it. Unless it's a question about string splitting in SQL Server...

Related

How to extract an uppercase word from a string in Postgresql only if entire word is in capital letters

I am trying to extract words from a column in a table only if the entire word is in uppercase letters (I am trying to find all acronyms in a column). I tried using the following code, but it gives me all capital letters in a string even if it is just the first letter of a word. Appreciate any help you can provide.
SELECT title, REGEXP_REPLACE(title, '[^A-Z]+', '', 'g') AS acronym
FROM table;
Here is my desired output:
title
acronym
I will leave ASAP
ASAP
David James is LOL
LOL
BTW I went home
BTW
Please RSVP today
RSVP
You could use this regular expression:
regexp_replace(title, '.*?\m([[:upper:]]+)\M.*', '\1 ', 'g')
.*? matches arbitrary letters is a non-greedy fashion
\m matches the beginning of a word
( is the beginning of the part we are interested in
[[:upper:]]* are arbitrarily many uppercase characters
) is the end of that part we are interested in
\M matches the end of a word
.* matches arbitrary characters
\1 references the part delimited by the parentheses
You could try REGEXP_MATCHES function
WITH data AS
(SELECT 'I will leave ASAP' AS title
UNION ALL SELECT 'David James is LOL' AS title
UNION ALL SELECT 'BTW I went home' AS title
UNION ALL SELECT 'Please RSVP today' AS title)
SELECT title, REGEXP_MATCHES(title, '[A-Z][A-Z]+', 'g') AS acronym
FROM data;
See demo here

Postgresql convert Japanese Full-Width to Half-Width

I am manipulating Japanese data and in some Japanese words, there are English words and Numbers are in.
SYSKEN, 松井ケ丘3, コメリH&G, 篠路7-1 are the examples.
I wanted to convert these English and Numbers in Full-width to half-width by throwing a function or any possible ways.
the output of the input above should be look-like "SYSKEN, 松井ケ丘3, コメリH&G, 篠路7-1"
If anyone knows the best way to start, I would appreciate it.
How about using translate() function?
-- prepare test data
CREATE TABLE address (
id integer,
name text
);
INSERT INTO address VALUES (1, 'SYSKEN, 松井ケ丘3, コメリH&G, 篠路7-1');
-- show test data
SELECT * from address;
-- convert Full-Width to Half-Width Japanese
UPDATE address SET name = translate(name,
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
);
-- see the converted data
SELECT * from address;
This code made the name column to "SYSKEN, 松井ケ丘3, コメリH&G, 篠路7-1".

How can I remove whitespace between static text elements on the same row? [duplicate]

Can nay one help to add multiple DB field values in one field.
Say i have 3 DB fields:
Name
Address
Age
I want to display all 3 fields in the same field:
John Peter 28.
I tried doing 3 fields next to each other and it did work but when i wrap text. It looks really bad:
Name
Jo.pe.28
hn te
r
My requirement is show data in one text field, for example: John.Peter.26
If you want to put them in one line (which i guess is the case), its straight forward.
Put this as a text box $F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
Or you can use string concatenation (I dont personally like the syntax, take more effort to understand) $F{Name}.concat(".").concat($F{Address}).concat(".").concat($F{Age})
The SQL Method
Why not concatenate all the 3 fields you need in the query you use itself like (Assuming you are with Postgres.),
select (name || address|| to_char(age)) as data from my_table
In Ireport
As suggested,
$F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
too works if needed to make it work from the report.
Make sure that all your fields are of same data type.

find alphabets and special characters in phone number field using an SQL query

I need to test if my phone number column values have any alphabets and special characters in the filed.
do you know something that can help?
SELECT distinct phone FROM table WHERE phone= PATINDEX('%[^0-9]%')
error i got:
Function patindex(unknown) doesnot exist.you might need to add explicit type casts.
table
name phone
ss (111)222-4444
xx (222)(333)4444
yy 223$36&888
zz 6738^3!#77 .ext
aa 777888stop
output (i would like to see this in my output)
name phone
yy 223$36&888
zz 6738^3!#77 .ext
aa 777888stop
my purpose of this is... i should clean up the phone number which has special characters and alphabets.
There are too many invalid chars, so I would like to test really for only numbers allowed.

How to show several fields values in one textField

Can nay one help to add multiple DB field values in one field.
Say i have 3 DB fields:
Name
Address
Age
I want to display all 3 fields in the same field:
John Peter 28.
I tried doing 3 fields next to each other and it did work but when i wrap text. It looks really bad:
Name
Jo.pe.28
hn te
r
My requirement is show data in one text field, for example: John.Peter.26
If you want to put them in one line (which i guess is the case), its straight forward.
Put this as a text box $F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
Or you can use string concatenation (I dont personally like the syntax, take more effort to understand) $F{Name}.concat(".").concat($F{Address}).concat(".").concat($F{Age})
The SQL Method
Why not concatenate all the 3 fields you need in the query you use itself like (Assuming you are with Postgres.),
select (name || address|| to_char(age)) as data from my_table
In Ireport
As suggested,
$F{Name} + "." + $F{Address} + "." + $F{Age}.toString()
too works if needed to make it work from the report.
Make sure that all your fields are of same data type.