Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I'm writing a select statement for select query in SQL 2005.
SELECT MID(Field1,1,5) FROM tbl_Table1 

but this gives an error, the 'mid' is not recognized built-in function name

I also try
SELECT SUBSTRING(Field1,1,5) FROM tbl_Table1

this is Woking.

But I want to select half part of the field like ABCDEFGH so I select only ABCD.

Another field Contains BCDFESDGSDFD then select BCDFESD string only.

Anyone, please help.

thanks in advance.
Posted
Updated 13-Dec-10 22:18pm
v3
Comments
Toniyo Jackson 14-Dec-10 2:33am    
Always put your code inside code block.
Dalek Dave 14-Dec-10 4:18am    
Edited for Grammar and Readability.

Will this help
SELECT LEFT(Field1, LEN(Field1) / 2) FROM tbl_Table1 
 
Share this answer
 
Comments
Dalek Dave 14-Dec-10 4:18am    
Good Answer
This query should work:
SELECT SUBSTRING(Field1,1,len(Field1)/2) FROM tbl_Table1
 
Share this answer
 
Try this,
SELECT SUBSTRING(Field1,1,len(Field1)/2) FROM tbl_Table1 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900