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 |
|
SQLGuruji
Starting Member
6 Posts |
Posted - 2010-01-20 : 09:04:06
|
| Hi,I need to run a query to select records from a table where values in a column are like "A,B,C,D,E,...."like"select * from table where alphabets >= A and alphabets <= D.The column data type of alphabets is "text"Thanks! |
|
|
shan
Yak Posting Veteran
84 Posts |
Posted - 2010-01-20 : 09:19:01
|
| Try this...select * from table where ASCII(Convert(varchar(1),alphabets)) >= 65 and ASCII(Convert(varchar(1),alphabets)) <= 68-Shan |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-20 : 09:25:45
|
What is your SQL Server version?Important: ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. text Variable-length non-Unicode data in the code page of the server and with a maximum length of 2^31-1 (2,147,483,647) charactersAre you sure you want to search a text field with maximum of 2,147,483,647 possible characters for a value like A????? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
SQLGuruji
Starting Member
6 Posts |
Posted - 2010-01-20 : 12:30:16
|
| Shan thanks your query worked great! and webfred thanks for your reply. |
 |
|
|
shan
Yak Posting Veteran
84 Posts |
Posted - 2010-01-21 : 08:56:53
|
| You are welcome-Shan |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-25 : 02:00:06
|
| orselect * from table where alphabets like '[A-D]%'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|