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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 grep like query command

Author  Topic 

sudo
Starting Member

1 Post

Posted - 2015-02-09 : 17:21:53
Hello SQLTEAM community. I am very new to SQL and have a question on a query.

SELECT column1, column 2, column3
FROM table1
WHERE column1 = "string"

This returns all the rows where column1 contains "string". Here is my question: In column 3, the data contains multiple lines such as:

Serial#: DSG5STFER24
RAM: $GB
HDD: 500GB

How can I parse column3 to just pull a specific line (i.e. Serial:#xxxxxxxxxx)?

bitsmed
Aged Yak Warrior

545 Posts

Posted - 2015-02-09 : 18:59:09
[code]select column1
,[column 2]
,column3
from table1
where column1='string'
and column3 like '%Serial:#xxxxxxxxxx%'[/code]
Edit: tags/formating corrected
Go to Top of Page
   

- Advertisement -