[T-SQL] Simplifying The Stored Procedure |
Simplifying The Stored Procedure Posted: 10 Jun 2013 12:30 AM PDT Hi Friends,In a new assignment as DBA, I am trying to make few codes better and have tasted some success, thanks to all the learnings from this forum. However, there is a stored procedure written in a pretty way but somehow I get very bad performance from this and was just trying to understand how it actually runs inside.You can find the procedure in the attachment. This somehow makes me thing that it is just like nested CTEs without using the word CTE anywhere and with CTEs, I never had pretty good experience when dealing with large data sets.Kindly recommend me that from development point of view, how this can be arranged in a meaningful way so that I can work with the dev team to make it look better. I work in non US working hours, so kindly bear with me in replying.PS: I have not inlcluded any table schema details or execution plan as of now.RegardsChandan |
Posted: 09 Jun 2013 09:20 AM PDT Hello EveryoneI would like to remove the '(999)' from the phone number that someone that did not know what they were doing, designed into this table. You should never place the area code and the phone number together. But this is from a DB2 developer. And now I am having to try and deal with it. But when I execute this query, I am getting this error:[quote][color=#FF0000]Conversion failed when converting the varchar value '(999)4746641' to data type int.[/color][/quote][code="sql"]DECLARE @PhoneNumber varchar(15)DECLARE @NewPhoneNumber varchar(15)SET @PhoneNumber = '(999)4746641'SET @NewPhoneNumber = REPLACE(@PhoneNumber,LEFT(5,@PhoneNumber),'')SELECT @PhoneNumber, @NewPhoneNumber[/code]I would like to remove or replace the area code and the parenthesis from the phone numberThank you in advance for all your assistance, suggestions and commentsAndrew SQLDBA |
You are subscribed to email updates from SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8) To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment