<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dejan Dozet</title>
    <description>The latest articles on DEV Community by Dejan Dozet (@dejandozet).</description>
    <link>https://dev.to/dejandozet</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2298255%2Ff98b8ffe-2ab2-4c58-b856-11140e1fb6aa.jpg</url>
      <title>DEV Community: Dejan Dozet</title>
      <link>https://dev.to/dejandozet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dejandozet"/>
    <language>en</language>
    <item>
      <title>Find Text in MSSQL Stored Procedures and Functions with a Custom Function</title>
      <dc:creator>Dejan Dozet</dc:creator>
      <pubDate>Thu, 31 Oct 2024 01:42:59 +0000</pubDate>
      <link>https://dev.to/dejandozet/find-text-in-mssql-stored-procedures-and-functions-with-a-custom-function-2h6k</link>
      <guid>https://dev.to/dejandozet/find-text-in-mssql-stored-procedures-and-functions-with-a-custom-function-2h6k</guid>
      <description>&lt;h2&gt;
  
  
  MSSQL Server Function: Find_Text_In_SP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Purpose
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;Find_Text_In_SP&lt;/code&gt; function is a table-valued function that searches for a specific text within the stored procedures, functions, and other objects in a SQL Server database. It identifies objects where the provided text pattern exists, making it useful for developers who need to locate text references in their SQL objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;@String1ToSearch&lt;/strong&gt;: &lt;code&gt;nvarchar(100)&lt;/code&gt; - The text pattern to search for within the SQL objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Return
&lt;/h3&gt;

&lt;p&gt;The function returns a table with two columns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt;: The name of the object (stored procedure, function, etc.) containing the search text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Type&lt;/strong&gt;: The type of SQL object, such as:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;P&lt;/code&gt; for Stored Procedure&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FN&lt;/code&gt; for Function&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;IF&lt;/code&gt; for Inline Table-Valued Function&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TF&lt;/code&gt; for Table-Valued Function&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;TR&lt;/code&gt; for Trigger&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;D&lt;/code&gt; for Default constraint&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Filtering Logic
&lt;/h3&gt;

&lt;p&gt;This function excludes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System-generated objects that start with &lt;code&gt;MSmerge&lt;/code&gt;, &lt;code&gt;dt_&lt;/code&gt;, &lt;code&gt;sp_cft&lt;/code&gt;, &lt;code&gt;sel_&lt;/code&gt;, &lt;code&gt;sp_sel&lt;/code&gt;, &lt;code&gt;sp_upd&lt;/code&gt;, and &lt;code&gt;sp_ins&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Specific procedure &lt;code&gt;GrantExectoAllProcedures_sp&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Text that matches &lt;code&gt;@String1ToSearch&lt;/code&gt; with a &lt;code&gt;-done!&lt;/code&gt; suffix.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example Usage
&lt;/h3&gt;

&lt;p&gt;To search for occurrences of the term "CustomerData" within stored procedures and functions, execute:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * FROM [dbo].[Find_Text_In_SP]('CustomerData');&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;This function is incredibly useful for quickly locating references within SQL objects, saving time and streamlining database management.&lt;/p&gt;

&lt;p&gt;For more details about it and much more similar posts, check this page on my blog where you can find &lt;code&gt;Find_Text_In_SP&lt;/code&gt; full implementation: &lt;a href="https://www.dejandozet.com/blog/searching-for-functions-on-the-server" rel="noopener noreferrer"&gt;Searching for Functions on the Server&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>mssql</category>
      <category>sqlfunctions</category>
      <category>textsearch</category>
      <category>sqlserver</category>
    </item>
    <item>
      <title>TADOConnection: Proper Use of LoginPrompt</title>
      <dc:creator>Dejan Dozet</dc:creator>
      <pubDate>Wed, 30 Oct 2024 11:43:16 +0000</pubDate>
      <link>https://dev.to/dejandozet/tadoconnection-proper-use-of-loginprompt-cob</link>
      <guid>https://dev.to/dejandozet/tadoconnection-proper-use-of-loginprompt-cob</guid>
      <description>&lt;p&gt;When using TADOConnection in Delphi, you may want to control when the login dialog appears. Setting LoginPrompt to True triggers the prompt each time a connection is attempted, which is useful if credentials aren’t stored in the connection string.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example Usage
&lt;/h2&gt;

&lt;p&gt;Here's an example illustrating conditional use of LoginPrompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;procedure TfrmMain.FormShow(Sender: TObject);
var
  i: integer;
begin
  con1.Provider := 'SQLOLEDB.1';
  con1.Properties['Application Name'].Value := Application.Title;
  with TIniFile.Create(ExtractFileDir(ParamStr(0)) + '\setup.ini') do
  begin
    con1.Properties['Initial Catalog'].Value := ReadString('database', 'Initial Catalog', '');
    con1.Properties['Data Source'].Value := ReadString('database', 'Data Source', '');
    if ReadBool('database', 'Integrated Security', false ) then
    begin
      con1.Properties['Integrated Security'].Value := 'SSPI';
      con1.Properties['Persist Security Info'].Value := 'False';
      con1.LoginPrompt := False;
    end
    else
    begin
      con1.Properties['Persist Security Info'].Value := 'True';
      con1.LoginPrompt := true;
    end;
  end;
end;

procedure TfrmMain.con1Login(Sender: TObject; Username, Password: string);
begin
  con1.Properties['User ID'].Value := Username;
  con1.Properties['Password'].Value := Password;
end;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the prompt appears only when credentials are missing, providing flexibility and enhancing security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Conditionally prompt: Use LoginPrompt based on your security needs.&lt;/li&gt;
&lt;li&gt;Avoid hardcoded credentials: Protect sensitive data when LoginPrompt is enabled.&lt;/li&gt;
&lt;li&gt;Consistent user experience: Keep the prompt behavior uniform across your app.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Using LoginPrompt wisely can simplify the user experience while ensuring secure access.&lt;/p&gt;

&lt;p&gt;For more details about it and much more similar posts, check this page on my blog: &lt;a href="https://www.dejandozet.com/blog/tadoconnection-correct-way-to-use-loginprompt-true" rel="noopener noreferrer"&gt;TADOConnection: Correct Way to Use LoginPrompt&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>delphi</category>
      <category>authentication</category>
      <category>bestpractices</category>
      <category>pascal</category>
    </item>
  </channel>
</rss>
