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 |
|
Ravi0435
Starting Member
47 Posts |
Posted - 2009-03-12 : 16:02:37
|
| Hi:I want to run a simple query Select * From Member_DetailWhere group_number like ('00491%')But i am in a process of something where-in i will need the query to work when i re-write it in the following way, i tried several methods and it looks simple but it does not work:None of the following work:------> 1SET QUOTED_IDENTIFIER OFFGOSelect * From Member_DetailWhere group_number like ("'"+ (substring('00491F001',1,5)+ '%')+"'")-------> 2SET QUOTED_IDENTIFIER OFFGODeclare @temp Varchar(10)Set @temp = ("'"+ (substring('00491F001',1,5)+ '%')+"'")Select * From Member_DetailWhere group_number like @temp--------> 3SET QUOTED_IDENTIFIER OFFGODeclare @temp Varchar(10)Set @temp = "('"+ (substring('00491F001',1,5)+ '%')+"')"Select * From Member_DetailWhere group_number like @temp------Any suggestions would be appreciated.thanks,RNothing much that i can do..!! |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-03-12 : 16:47:27
|
| what exactly are you looking for? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-12 : 16:48:42
|
SET QUOTED_IDENTIFIER OFFGOSelect * From Member_DetailWhere group_number like substring('00491F001', 1, 5) + '%'-------> 2SET QUOTED_IDENTIFIER OFFGODeclare @temp Varchar(10)Set @temp = substring('00491F001', 1, 5) + '%'Select * From Member_DetailWhere group_number like @temp--------> 3SET QUOTED_IDENTIFIER OFFGODeclare @temp Varchar(10)Set @temp = substring('00491F001', 1, 5) + '%'Select * From Member_DetailWhere group_number like @temp E 12°55'05.63"N 56°04'39.26" |
 |
|
|
Ravi0435
Starting Member
47 Posts |
Posted - 2009-03-13 : 09:41:58
|
| Thanks "PESO"....it worked ...i wonder how did i miss that...i tried all the possibilities even constructed parenthesis before and after the single quotes...thanks again.still wondering whats the difference? like ("'"+ (substring('00491F001',1,5)+ '%')+"'") and like substring('00491F001', 1, 5) + '%'or for that matter: like (substring('00491F001',1,5)+ '%') and like substring('00491F001', 1, 5) + '%'Only if you have time-answer, if not its fine as long as it works..!!thanks again.thanks,RNothing much that i can do..!! |
 |
|
|
|
|
|
|
|