<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SysBlog &#187; MSSQL Database Development</title>
	<atom:link href="http://blog.interakt.hr/?cat=3&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://blog.interakt.hr</link>
	<description>...mic po mic...</description>
	<lastBuildDate>Tue, 24 Mar 2026 11:53:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>ColdFusion/MSSQL &#8211; new line and LIKE</title>
		<link>https://blog.interakt.hr/?p=971</link>
		<comments>https://blog.interakt.hr/?p=971#comments</comments>
		<pubDate>Tue, 24 Mar 2026 11:52:41 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[Coldfusion]]></category>
		<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=971</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">

SELECT id, ownership
					FROM tbl_test
					WHERE 

				lang = &lt;cfqueryparam cfsqltype=&quot;cf_sql_char&quot; maxlength=&quot;2&quot; value=&quot;en&quot;&gt;
				and 

				(
					REPLACE(REPLACE(ownership, CHAR(13), ''), CHAR(10), '') like &lt;cfqueryparam value=&quot;%#reReplace(arguments.real_beneficiaries, &quot;[\r\n]&quot;, &quot;&quot;, &quot;all&quot;)#%&quot; cfsqltype=&quot;cf_sql_nvarchar&quot;&gt;
					OR
					REPLACE(REPLACE(ownership, CHAR(13), ''), CHAR(10), '') like &lt;cfqueryparam value=&quot;#reReplace(arguments.real_beneficiaries, &quot;[\r\n]&quot;, &quot;&quot;, &quot;all&quot;)#%&quot; cfsqltype=&quot;cf_sql_nvarchar&quot;&gt;
					OR
					REPLACE(REPLACE(ownership, CHAR(13), ''), CHAR(10), '') like &lt;cfqueryparam value=&quot;%#reReplace(arguments.real_beneficiaries, &quot;[\r\n]&quot;, &quot;&quot;, &quot;all&quot;)#&quot; cfsqltype=&quot;cf_sql_nvarchar&quot;&gt;
					OR
					REPLACE(REPLACE(ownership, CHAR(13), ''), CHAR(10), '') = &lt;cfqueryparam value=&quot;#reReplace(arguments.real_beneficiaries, &quot;[\r\n]&quot;, &quot;&quot;, &quot;all&quot;)#&quot; cfsqltype=&quot;cf_sql_nvarchar&quot;&gt;

					)
</pre>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=971</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL &#8211;  DATE and </title>
		<link>https://blog.interakt.hr/?p=966</link>
		<comments>https://blog.interakt.hr/?p=966#comments</comments>
		<pubDate>Tue, 08 Apr 2025 08:03:32 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=966</guid>
		<description><![CDATA[2019-10-16 2011-04-13 2014-06-13 2014-06-18 2012-03-29 2012-03-29 2022-05-20 2023-01-11 2022-05-05 2022-12-09 2021-06-21 2021-06-21]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">SELECT TOP 5 LEFT(DATEOPEN, 10) FROM tbl_dates  where LEFT(DATEOPEN, 10) &lt; '2021-01-01'</pre>
<p>2019-10-16<br />
2011-04-13<br />
2014-06-13<br />
2014-06-18<br />
2012-03-29<br />
2012-03-29</p>
<pre class="brush: plain; title: ; notranslate">SELECT TOP 5 LEFT(DATEOPEN, 10) FROM tbl_dates where LEFT(DATEOPEN, 10) &gt; '2021-01-01'</pre>
<p>2022-05-20<br />
2023-01-11<br />
2022-05-05<br />
2022-12-09<br />
2021-06-21<br />
2021-06-21</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=966</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL: truncate all tables from schema with &#8216;test&#8217; in the table name</title>
		<link>https://blog.interakt.hr/?p=960</link>
		<comments>https://blog.interakt.hr/?p=960#comments</comments>
		<pubDate>Fri, 21 Mar 2025 13:04:52 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=960</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">

DECLARE @sql NVARCHAR(MAX) = ''

SELECT @sql = @sql + 'TRUNCATE TABLE  [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] ' + CHAR(10)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'MYSCHEMA'  -- Change this to your schema
AND TABLE_NAME LIKE '%test%'  -- Find tables containing 'test' in the name

PRINT @sql  -- Check the generated SQL (optional)
EXEC sp_executesql @sql  -- Execute the truncation
</pre>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=960</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL &#8211; variables</title>
		<link>https://blog.interakt.hr/?p=953</link>
		<comments>https://blog.interakt.hr/?p=953#comments</comments>
		<pubDate>Thu, 16 Jan 2025 12:08:00 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=953</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">DECLARE @query_date DATE = '2025-01-15'
SELECT * from tbl_dates WHERE mydate = @query_date</pre>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=953</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL &#8211; REMOVE non-alphabetic characters from string</title>
		<link>https://blog.interakt.hr/?p=935</link>
		<comments>https://blog.interakt.hr/?p=935#comments</comments>
		<pubDate>Wed, 27 Mar 2024 07:35:38 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=935</guid>
		<description><![CDATA[source: https://stackoverflow.com/questions/1007697/how-to-strip-all-non-alphabetic-characters-from-string-in-sql-server]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">

Create Function [dbo].[RemoveNonAlphaCharacters](@Temp VarChar(1000))
Returns VarChar(1000)
AS
Begin

    Declare @KeepValues as varchar(50)
    Set @KeepValues = '%[^a-z]%'
    While PatIndex(@KeepValues, @Temp) &gt; 0
        Set @Temp = Stuff(@Temp, PatIndex(@KeepValues, @Temp), 1, '')

    Return @Temp
End

Select dbo.RemoveNonAlphaCharacters('abc1234def5678ghi90jkl')
</pre>
<p>source: https://stackoverflow.com/questions/1007697/how-to-strip-all-non-alphabetic-characters-from-string-in-sql-server</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=935</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL: Get size in KB of all database tables</title>
		<link>https://blog.interakt.hr/?p=910</link>
		<comments>https://blog.interakt.hr/?p=910#comments</comments>
		<pubDate>Mon, 23 Oct 2023 10:31:36 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=910</guid>
		<description><![CDATA[Source: https://stackoverflow.com/questions/7892334/get-size-of-all-tables-in-database]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">SELECT
t.name AS TableName,
s.name AS SchemaName,
p.rows,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,
CAST(ROUND(((SUM(a.total_pages) - SUM(a.used_pages)) * 8) / 1024.00, 2) AS NUMERIC(36, 2)) AS UnusedSpaceMB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.object_id = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.object_id AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
LEFT OUTER JOIN
sys.schemas s ON t.schema_id = s.schema_id
WHERE
t.name NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.object_id &amp;gt; 255
GROUP BY
t.name, s.name, p.rows
ORDER BY
TotalSpaceMB DESC, t.name
</pre>
<p>Source: https://stackoverflow.com/questions/7892334/get-size-of-all-tables-in-database</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=910</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL: select only row with max value</title>
		<link>https://blog.interakt.hr/?p=902</link>
		<comments>https://blog.interakt.hr/?p=902#comments</comments>
		<pubDate>Thu, 04 May 2023 10:49:16 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=902</guid>
		<description><![CDATA[Another approach for http://blog.interakt.hr/?p=610 SOURCE: https://stackoverflow.com/questions/38912808/select-only-row-with-maxid-in-sql-server]]></description>
			<content:encoded><![CDATA[<p>Another approach for http://blog.interakt.hr/?p=610</p>
<pre class="brush: plain; title: ; notranslate">
select
	id, case_id, file_path, date_created
  from (
        select id, case_id, file_path, date_created, row_number() over (partition by case_id order by date_created desc) as rn
         from TMP_reminders
        ) as dtbl_unique_reminders
  where dtbl_unique_reminders.rn = 1
</pre>
<p>SOURCE: https://stackoverflow.com/questions/38912808/select-only-row-with-maxid-in-sql-server</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=902</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL &#8211; get file extension from file name</title>
		<link>https://blog.interakt.hr/?p=898</link>
		<comments>https://blog.interakt.hr/?p=898#comments</comments>
		<pubDate>Sat, 25 Feb 2023 12:21:53 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=898</guid>
		<description><![CDATA[source: https://stackoverflow.com/questions/16783026/t-sql-get-file-extension-name-from-a-column]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate"> select (case when FileName like '%.%' then reverse(left(reverse(FileName), charindex('.', reverse(FileName)) - 1)) else '' end) as File_Extension</pre>
<p>source: https://stackoverflow.com/questions/16783026/t-sql-get-file-extension-name-from-a-column</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=898</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL: find string in string</title>
		<link>https://blog.interakt.hr/?p=895</link>
		<comments>https://blog.interakt.hr/?p=895#comments</comments>
		<pubDate>Wed, 07 Dec 2022 12:08:38 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=895</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">

SELECT * FROM tbl_companies WHERE CHARINDEX('test', Company_name) &gt; 0 
</pre>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=895</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSSQL &#8211; calculate season</title>
		<link>https://blog.interakt.hr/?p=889</link>
		<comments>https://blog.interakt.hr/?p=889#comments</comments>
		<pubDate>Sun, 13 Nov 2022 11:38:01 +0000</pubDate>
		<dc:creator>SysBlog</dc:creator>
				<category><![CDATA[MSSQL Database Development]]></category>

		<guid isPermaLink="false">http://blog.interakt.hr/?p=889</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">

SELECT
(case
		when month(GETDATE()) = 12  then case when day(GETDATE()) &lt; 21 then 'autumn' else 'winter' end
		when month(GETDATE()) in ( 1,2 ) then 'winter'
		when month(GETDATE()) = 3 then case when day(GETDATE()) &lt; 21 then 'winter' else 'spring' end
		when month(GETDATE()) in ( 4, 5 ) then 'spring'
		when month(GETDATE()) = 6  then case when day(GETDATE()) &lt; 21 then 'spring' else 'summer' end
		when month(GETDATE()) in ( 7, 8 ) then 'summer'
		when month(GETDATE()) = 9  then case when day(GETDATE()) &lt; 23 then 'summer' else 'autumn' end
		when month(GETDATE()) in ( 10, 11 ) then 'autumn'
end) as season
</pre>
]]></content:encoded>
			<wfw:commentRss>https://blog.interakt.hr/?feed=rss2&#038;p=889</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
