Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Execute SQL Task issue Expand / Collapse
Author
Message
Posted Tuesday, February 12, 2013 7:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 6:14 AM
Points: 6, Visits: 10
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
Post #1418947
Posted Tuesday, February 12, 2013 7:13 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
REPLACE(Stage,'Closed Won','Awarded')

Mack

Post #1418951
Posted Tuesday, February 12, 2013 7:18 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 6:14 AM
Points: 6, Visits: 10
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.
Post #1418953
Posted Tuesday, February 12, 2013 7:20 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
Can ou post all of your query - also the column name is [stage] right?

Mack
Post #1418955
Posted Tuesday, February 12, 2013 7:21 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 11:10 AM
Points: 1,269, Visits: 3,631
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.
Post #1418956
Posted Tuesday, February 12, 2013 7:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 6:14 AM
Points: 6, Visits: 10
Hi Mack,

I attached a screen shot from SSIS which shows the statement. Stage is the correc col. name.


  Post Attachments 
SSIS screen shot.docx (12 views, 93.39 KB)
Post #1418959
Posted Tuesday, February 12, 2013 7:27 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
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
Post #1418960
Posted Tuesday, February 12, 2013 7:30 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:10 AM
Points: 5,437, Visits: 10,129
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
Post #1418963
Posted Tuesday, February 12, 2013 7:41 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 25, 2014 6:14 AM
Points: 6, Visits: 10
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.
Post #1418971
Posted Tuesday, February 12, 2013 7:45 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
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
Post #1418972
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse