SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Replace and Concat
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jd343
Starting Member

8 Posts

Posted - 11/26/2012 :  15:04:47  Show Profile  Reply with Quote
Hello There

Thank you for taking time to read this post.

I have an application I use to import a csv file from suppliers. The application processes the file then

uploads to a shopping cart products.

The application allows you to edit files using mysql make changes to it before upload. I want to change

the categories names in the file to my own ones- on the fly rather than having to import into excel first

change manually then use the edited csv file, and then add other categories names to that replaced value.

Bascially I want to know correct way of using REPLACE and CONCAT together.

For example a column 6 in supplier files represent the suppliers Categories.

REPLACE([CSV_COL(6)],'Notebook','Laptop')

this correctly changes all category Names in supplier file from Notebook to Laptop

secondly

CONCAT("Default Category|Computers|",[CSV_COL(6)])

This adds
Default Category|Computers in front of whatever the value is in column 6 which carrying on from the

example above would be Notebook

So final category location would be

Default Category|Computers|Notebook

BUT I am trying to get it to add the REPLACED value at the end so it looks like this.

Default Category|Computers|Laptop

Please can anyone explain how I would achieve this

join these 2 together or any other way to achieve what i want to do.

REPLACE([CSV_COL(6)],'Notebook','Laptop')

CONCAT("Default Category|Computers|",[CSV_COL(6)])

Regards

bitsmed
Constraint Violating Yak Guru

422 Posts

Posted - 11/26/2012 :  16:18:08  Show Profile  Reply with Quote
This forum is for MS SQL Server, but as your question is generic sql, you might want to try this:

concat('Default Category|Computers|',replace([csv_col(6)],'Notebook','Laptop'))
Go to Top of Page

jd343
Starting Member

8 Posts

Posted - 11/26/2012 :  17:06:19  Show Profile  Reply with Quote
thank you for your help.

It brings error saying it Cannot evaluate expression check syntax

any ideas please?

Thank you once again for the help. much appreciated
Go to Top of Page

jd343
Starting Member

8 Posts

Posted - 11/26/2012 :  17:31:34  Show Profile  Reply with Quote
please ignore above comment bitsmed thank you Very Much your solution works correct. Really Appreciate your help very kind of of you. Spent along time trying to make it work and you have made me very happy.

I want to try to achieve 2 things more with this but I want to try first if I can not get it correct I will post on here.

Will keep updated.

Much appreciated
Go to Top of Page

jd343
Starting Member

8 Posts

Posted - 11/27/2012 :  14:56:08  Show Profile  Reply with Quote
I am trying to add more categories to the expression above

concat('Default Category|Computers|',replace([csv_col(6)],'Notebook','Laptop'))

for example Printer to Laser

I have alot of categories to replace but I find I get error with syntax if I just add comma and and next values to replace.

concat('Default Category|Computers|',replace([csv_col(6)],'Notebook','Laptop'))
what is the correct and easy way to make a list of values to replace please.

Kind Regards
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000