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 |
|
sondurak
Starting Member
3 Posts |
Posted - 2011-01-31 : 04:21:37
|
| hello everyone, hope i found a solution about my problem.I have a table with long strings like :ID | STRING_COLUMN__|_______________________________________________________________1 | 'this is the long string in ID="xyz-23d-343" specific column'2 | 'this is another long string in ID="abc-423-i25' given column'...And i would like to get the id values in this records with a subtlequery such as;> DECLARE @id ntext> while 1> begin> select id from MyTable where STRING_COLUMN > like '%ID="' + ( @id = '%' ) + '"%' --<========= attention here >> print @id -- this line is supposed to write id values -- as xyz-23d-343 or abc-423-i25> ...bla blaCan I Do This?, why? how can i fix the line, what should i do?i want it without digging into details of substring(), len() operations.Any ideas? |
|
|
Sachin.Nand
2937 Posts |
Posted - 2011-01-31 : 04:29:13
|
| What values are you going to set in @id ?PBUH |
 |
|
|
sondurak
Starting Member
3 Posts |
Posted - 2011-01-31 : 04:46:06
|
quote: Originally posted by Sachin.Nand What values are you going to set in @id ?PBUH
Thanks for interest Sachin.Nand,@id value will get the substring in the STRING_COLUMN value.in my examplefor first iteration in the while loop, select statement will get ID values in a table form but i am considering with print statement.for each row @id value should contain values "xyz-23d-343", "abc-423-i25" respectively.I want to get substrings of STRING_COLUMN, and assigned into the@id ntext variable. ..like '%ID="' + ( @id = '%' ) + '"%'.. would assign @id after matching. query is missing somethingbut i dont know if i head to the right way.i suppose communication flows without misunderstanding among us. |
 |
|
|
sondurak
Starting Member
3 Posts |
Posted - 2011-01-31 : 06:55:07
|
| Couldn't I explain what i want to do? |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-01-31 : 08:39:12
|
| wouldn't string_column like '%' +@id + '%' work?JimEveryday I learn something that somebody else already knew |
 |
|
|
|
|
|