Solved

sql left and charindexfunction

Posted on 2011-09-20
3
207 Views
Last Modified: 2012-05-12
Can anyone please tell why this is erroring out

select            
case  
when isnumeric(left('2022AVEQENSLEY',case when charindex(char(32),'2022AVEQENSLEY')
            =0 then 2
            else charindex(char(32),'2022AVEQENSLEY') end -1)) = 1
then left('2022AVEQENSLEY',charindex(char(32),'2022AVEQENSLEY')-1)
else replace(replace('2022AVEQENSLEY',char(32),''),'.','')
end
      
0
Comment
Question by:baylar
3 Comments
 
LVL 32

Expert Comment

by:ewangoya
ID: 36571124

This returns 0
charindex(char(32),'2022AVEQENSLEY')

Then you actually reduce it by -1
else charindex(char(32),'2022AVEQENSLEY') end -1))

You can not pass -1 to CHARINDEX function
0
 
LVL 29

Accepted Solution

by:
QPR earned 500 total points
ID: 36571125
0
 

Author Closing Comment

by:baylar
ID: 36571246
Awesome works the way I want.
Thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now