.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

How to replace first occurrence of word in TSQL

Posted By: Sajid P K     Posted Date: October 11, 2010    Points:2   Category :Sql Server
Dear Frnds,

Could please tell me best way to replace first occurrence of word in Tsql ?

Eg:

SET @SQL = 'select 1 as X, 1 as Y, 3 as z from

(

Select * from Table1

)

I wnt to replace first "select" to another word.


Responses
Author: Deco             
Posted Date: October 11, 2010     Points: 5   

Please try the below code

SELECT LEFT(@SQL, CHARINDEX(' ', @SQL))


Regards,
Deco


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend