Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 replace problem

Author  Topic 

nisar
Starting Member

29 Posts

Posted - 2010-03-07 : 01:25:48
Hi,

I am running one query like this

'left join dbo.IMP_101_DUEIN di on (di.duodocnoact+di.duodocnoorg+di.duodocnoshop+di.duodocnoserial)=
replace(p.doc_ctrl_no,'-','')'

whenever I do this I get error like this

Invalid operator for data type. Operator equals subtract, type equals varchar.


Whenever I remove replace statement it works fine
any substitue for replace command or changes in
this statement will any body suggest

Regards
Nisar

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-07 : 01:57:33
it should be

'left join dbo.IMP_101_DUEIN di on (di.duodocnoact+di.duodocnoorg+di.duodocnoshop+di.duodocnoserial)=
replace(p.doc_ctrl_no,''-'','''')'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nisar
Starting Member

29 Posts

Posted - 2010-03-07 : 02:01:38
great it works.

thank you very much.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-07 : 02:08:20
reason is this

http://beyondrelational.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -