Solved

sql left and charindexfunction

Posted on 2011-09-20
3
198 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

743 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

14 Experts available now in Live!

Get 1:1 Help Now