How to search string / substring in SSMS results?

It seems pretty simple, but for some reason I don't find anything on how to do this. I am using SQL Server Management Studio 2012, and I have a set of results returned from a SELECT query, say select a,b from x. How can I search in a column bfor a substring? In Access, I would click on the column and type Ctrl + F, but in SSMS, which seems to be used only to search for SQL itself, and not for the results. How can I search for results? I know that I can modify my query to return this result, for example:

select a,b from x where b like '*hello*'

but I want to get all returned rows, not just one.

UPDATE: The answers I get relate to how to create a query that selects only the rows that I am looking for, which, as I indicated above, is not what I am looking for. I want all the rows to be returned, and I want to look in the search results in the SSMS interface to find the desired values. The reason is because I want to see these values ​​in the context of other strings that don't have them.

+3
source share
4 answers

In SQL Server Management Studio, you can output the query results to text (CTRL + T), re-run your query, click in the results pane and CTRL + F to find the rows from the unfiltered query. To return the query results to the grid, press CTRL + D.

+6
source

Using:

select a,b from x where b like '%hello%'

Or:

select a,b from x where charindex('hello',b)>0

CHARINDEX is much faster than LIKE.

+1

SSMS .

That's why I added this function to my add-in ( SSMSBoost ): it allows you to search the results grid using wildcards, there are other add-ons that allow you to do this.

+1
source

select a, substring (b, 2, 3) as b from x

0
source

Source: https://habr.com/ru/post/1693899/


All Articles