January 25, 2018 at 10:56 am
hi there
I have a folder of .sql scripts, in a windows path 'E:\DeploymentScripts'.
I want to be able to search inside the code on all scripts for a keyword say for example 'StoredProcedureTest'
Does anyone know how i can do this in t-sql?
January 25, 2018 at 1:33 pm
Hi,
If that is not in a database you can't use t-sql. Because your files on disk you can use windows explorer advanced search with file content enabled - https://www.lifehacker.com.au/2015/09/set-windows-10-to-search-all-file-contents-with-this-setting/
January 25, 2018 at 1:42 pm
Or use a tool like FileSeek, which is very useful if you have all of your .sql files stored locally in a VCS.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
January 25, 2018 at 2:02 pm
Weegee2017 - Thursday, January 25, 2018 10:56 AMhi thereI have a folder of .sql scripts, in a windows path 'E:\DeploymentScripts'.
I want to be able to search inside the code on all scripts for a keyword say for example 'StoredProcedureTest'Does anyone know how i can do this in t-sql?
Contrary to what has been stated, this can be done in SQL Server. The question is, do you really need to do the search from SQL Server or other the suggestions from the others OK for you?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 25, 2018 at 5:35 pm
Weegee2017 - Thursday, January 25, 2018 10:56 AMhi thereI have a folder of .sql scripts, in a windows path 'E:\DeploymentScripts'.
I want to be able to search inside the code on all scripts for a keyword say for example 'StoredProcedureTest'Does anyone know how i can do this in t-sql?
DECLARE @tbl table
(
Id int IDENTITY
PRIMARY KEY
, [Dir-File] varchar(255)
, Depth tinyint
, IsFile bit
);
INSERT @tbl
(
[Dir-File]
, Depth
, IsFile
)
EXEC sys.xp_dirtree
'E:\DeploymentScripts'
, 0
, 1;
SELECT DISTINCT
'E:\DeploymentScripts' + t1.[Dir-File] + '\' + t2.[Dir-File] + '\' + t3.[Dir-File] Files
FROM
@tbl t1
JOIN @tbl t2 ON t2.Depth > t1.Depth
AND t2.Id > t1.Id
JOIN @tbl t3 ON t3.Depth > t1.Depth
AND t3.Depth > t2.Depth
AND t3.Id > t1.Id
AND t3.Id > t2.Id
ORDER BY January 26, 2018 at 3:00 am
Jeff Moden - Thursday, January 25, 2018 2:02 PMWeegee2017 - Thursday, January 25, 2018 10:56 AMhi thereI have a folder of .sql scripts, in a windows path 'E:\DeploymentScripts'.
I want to be able to search inside the code on all scripts for a keyword say for example 'StoredProcedureTest'Does anyone know how i can do this in t-sql?
Contrary to what has been stated, this can be done in SQL Server. The question is, do you really need to do the search from SQL Server or other the suggestions from the others OK for you?
FINDSTR via XP_CMDSHELL 😉
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply