| 
                
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. 
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | kamii47Constraint Violating Yak Guru
 
 
                                        353 Posts | 
                                            
                                            |  Posted - 2013-02-20 : 06:21:21 
 |  
                                            | Any simple way to get querystring value from a url without charindex and substringI wanted to get the querystring value of entryidhttp://www.mysite.com/Default.aspx?TabId=330&EntryId=1Kamran ShahidPrinciple Engineer Development(MCSD.Net,MCPD.net) |  |  
                                    | James KMaster Smack Fu Yak Hacker
 
 
                                    3873 Posts | 
                                        
                                          |  Posted - 2013-02-20 : 07:48:29 
 |  
                                          | Are you running into any issues when using charindex and substring? In any case, the following does not use either of those functions: DECLARE @x VARCHAR(256) = 'http://www.mysite.com/Default.aspx?TabId=330&EntryId=1';SELECT STUFF(@x,1,PATINDEX('%&EntryId%',@x),'') |  
                                          |  |  |  
                                    | donjosdonStarting Member
 
 
                                    1 Post | 
                                        
                                          |  Posted - 2014-04-11 : 06:22:06 
 |  
                                          | I tried the below and it worked.DECLARE @x VARCHAR(256) = 'http://www.mysite.com/Default.aspx?EntryId = 1&a=1&TabId=330';--another query string combination/*DECLARE @x VARCHAR(256) = 'http://www.mysite.comDefault.aspx?TabId=330&EntryId = 1&a=1';*/SELECT STUFF(@x,1,PATINDEX('%EntryId%',@x)-1,'')select LTRIM(RTRIM(Replace(REPLACE(SUBSTRING(STUFF(@x,1,PATINDEX('%EntryId%',@x)-1,''),0, (case when CHARINDEX('&',STUFF(@x,1,PATINDEX('%EntryId%',@x)-1,''),1)=0 then 100 else CHARINDEX('&',STUFF(@x,1,PATINDEX('%EntryId%',@x)-1,''),1) end)),'EntryId',''),'=','')))ThanksJoseph Don |  
                                          |  |  |  
                                |  |  |  |  |  |