AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Sqlpro search for coulmn10/3/2023 ![]() ![]() (Attention: This example does not do any check of the GET Variable which could be potentially used for SQL injection. $search_query = "search_string LIKE '%$word%'" If you are using the SQL from another language like PHP, you can add the part behind the WHERE using a loop. WHERE search_string LIKE '%Hans%' AND search_string LIKE '%Muster%' (SELECT PersonID, CONCAT(Firstname, ' ', Name, ' ', Cellphone, ' ',Įmail, ' ', Place) search_string FROM person) as all_in_one The code would than look the following way: SELECT Firstname, Name, Place Let's suppose we have a table person with the columns PersonID, Firstname, Name, Cellphone, Email and Place, which should all be search and The full name including the Place should be outputet. This has the benefit that we do not have to add an extra column to the database. IF found a fast way after reading the answer of Jose Hernandez Naranjo using a subquery. WHERE SYST.name IN ('varchar','nvarchar','text','ntext','char','nchar') JOIN sys.types SYST ON ST.system_type_id=er_type_idĪND ST.system_type_id=SYST.system_type_id Viewed 489 times 0 So basically I have a column called query which contains a query. Learn more about Teams Using Sequel Pro: How do I update a column that contains a query Ask Question Asked 3 years ago. JOIN sys.types ST ON C.user_type_id=ST.user_type_id Connect and share knowledge within a single location that is structured and easy to search. JOIN sys.schemas SC ON SC.schema_id=T.schema_id - AND SC.name = '' ![]() JOIN sys.tables T ON C.object_id=T.object_id QUOTENAME(SC.name) + '.' + QUOTENAME(T.name) + ' WHERE ' + QUOTENAME(C.name) + SELECT = + 'SELECT CONVERT(VARCHAR(MAX),COUNT(*)) + '' matches in column ''+''' Enter the string to be searched for here : You can add additional data types to the WHERE clause to include other types, as well as adding a schema name to the JOIN (commented below) to limit your search, if needed. I can't take credit, but I found this and it works perfectly. SET = - 2) - remove last can of course change DECLARE NVARCHAR(100) = 'TARGET_TABLE' into parameter of the stored procedure.ĮXEC SearchSpecificTable = 'needle_to_find' CREATE PROC nvarchar(100)ĭECLARE NVARCHAR(MAX) = 'SELECT * FROM ' + +' WHERE '
0 Comments
Read More
Leave a Reply. |