|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 12:31 PM
Points: 6,
Visits: 6
|
|
I am trying to use the REPLACE function with no success. I have a Column name "Stage". In the column I need to find the value "Closed Won" and replace it with the value of "Awarded".
I've tried variations of this statement but this is the jist of it.
REPLACE("Closed Won","Closed Won","Awarded")
It stops with the following erorr which has proven to be little help.
[Execute SQL Task] Error: Executing the query "REPLACE("Closed Won","Closed Won","Awarded")" failed with the following error: "Incorrect syntax near 'Closed Won'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Thank you for your help.
Erik
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:58 AM
Points: 117,
Visits: 458
|
|
REPLACE(Stage,'Closed Won','Awarded')
Mack
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 12:31 PM
Points: 6,
Visits: 6
|
|
Hi Mack,
Thank you for the reponse. I used the statement and it returned the following.
[Execute SQL Task] Error: Executing the query "REPLACE(Stage,'Closed Won','Awarded')" failed with the following error: "Incorrect syntax near 'Stage'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:58 AM
Points: 117,
Visits: 458
|
|
Can ou post all of your query - also the column name is [stage] right?
Mack
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 11:31 AM
Points: 1,157,
Visits: 3,077
|
|
REPLACE ( string_expression , string_pattern , string_replacement )
SELECT REPLACE ( 'closed won' , 'closed won', 'award') the string_expression can be a column, variable, or string.
______________________________________________________________________________________________ Forum posting etiquette. Get your answers faster.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 12:31 PM
Points: 6,
Visits: 6
|
|
Hi Mack,
I attached a screen shot from SSIS which shows the statement. Stage is the correc col. name.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:58 AM
Points: 117,
Visits: 458
|
|
Your SQL statement needs to be a proper statement ie
Select REPLACE(Stage,'Closed Won','Awarded') from your_table
What are you trying to do? An update? Assign a variable?
Mack
|
|
|
|
|
SSCarpal Tunnel
       
Group: General Forum Members
Last Login: Yesterday @ 9:56 AM
Points: 4,418,
Visits: 7,156
|
|
The REPLACE statement doesn't update the table for you. All it does is return the first expression but with any occurrence of the second expression replaced by the third expression. If you want to update your table then you need to put your REPLACE statement into an UPDATE statement.
John
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, February 12, 2013 12:31 PM
Points: 6,
Visits: 6
|
|
Hi,
I was able to get it to run with out error using calvo's statement and also Mack's statement. The only issue is that the value of Closed Won is not being replaced with Awarded.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Yesterday @ 3:58 AM
Points: 117,
Visits: 458
|
|
What do you want the SQL task to do? Update the column?
If so the SQL needs to be
Update table_name Set stage = REPLACE(Stage,'Closed Won','Awarded')
Mack
|
|
|
|