<?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>Functions &#8211; SQLpowered.com</title>
	<atom:link href="https://sqlpowered.com/script-category/functions/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlpowered.com</link>
	<description>SQL Server + BI</description>
	<lastBuildDate>Tue, 16 Jan 2024 08:58:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://sqlpowered.com/wp-content/uploads/2020/07/FavIcon-e1594067873682-99x100.png</url>
	<title>Functions &#8211; SQLpowered.com</title>
	<link>https://sqlpowered.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Recreate All Inline Table Valued Functions</title>
		<link>https://sqlpowered.com/script/recreate-all-inline-table-valued-functions/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Tue, 16 Jan 2024 08:58:04 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=5663</guid>

					<description><![CDATA[You can use this script to recreate all inline table-valued functions in case database collation or underlying schema has been changed. You can use it to refresh all sql modules when the filter will be removed. SET NOCOUNT ON DECLARE @Object_Id INT DECLARE @Object_Name NVARCHAR(500) DECLARE @Definition NVARCHAR(MAX) DECLARE @Stmt...]]></description>
										<content:encoded><![CDATA[<p>You can use this script to recreate all inline table-valued functions in case database collation or underlying schema has been changed. You can use it to refresh all sql modules when the filter will be removed.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">SET NOCOUNT ON

DECLARE @Object_Id INT
DECLARE @Object_Name NVARCHAR(500)
DECLARE @Definition NVARCHAR(MAX)
DECLARE @Stmt NVARCHAR(MAX)

DECLARE @Modules TABLE (
	[object_id] INT NOT NULL PRIMARY KEY,
	[object_name] NVARCHAR(500) NOT NULL,
	[definition] NVARCHAR(MAX) NOT NULL
)

INSERT INTO @Modules
	(	[object_id], [object_name], [definition] )
	SELECT 
		[m].[object_id], QUOTENAME([s].[name]) + '.' + QUOTENAME([o].[name]), [m].[definition]
	FROM [sys].[sql_modules] [m]
		INNER JOIN [sys].[objects] [o] ON [o].[object_id] = [m].[object_id]
		INNER JOIN [sys].[schemas] [s] ON [s].[schema_id] = [o].[schema_id]
	WHERE [o].[type_desc] = 'SQL_INLINE_TABLE_VALUED_FUNCTION' AND [m].[is_inlineable] = 1
	ORDER BY [s].[name], [o].[name]

WHILE EXISTS (SELECT * FROM @Modules)
BEGIN
    
	SELECT TOP(1) 
		@Object_Id = [object_id],
		@Object_Name = [object_name],
		@Definition = [definition]
	FROM @Modules
	ORDER BY [object_id]

	PRINT @Object_Name

	SET @Stmt = 'DROP FUNCTION ' + @Object_Name + ';'

	EXEC [sys].[sp_executesql] @Stmt

	EXEC [sys].[sp_executesql] @Definition

	DELETE FROM @Modules WHERE [object_id] = @Object_Id

END
GO</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Drop all functions in database</title>
		<link>https://sqlpowered.com/script/drop-all-functions-in-database/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Mon, 13 Aug 2018 19:53:34 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=2719</guid>

					<description><![CDATA[DECLARE @Stmt NVARCHAR(MAX) SET @Stmt = '' SELECT @Stmt = @Stmt + 'DROP FUNCTION [' + s.name + '].[' + o.name + '];' FROM sys.objects o INNER JOIN sys.schemas s ON s.schema_id = o.schema_id WHERE type_desc LIKE '%FUNCTION%' EXECUTE (@Stmt) GO SELECT * FROM sys.objects WHERE type_desc LIKE '%FUNCTION%' GO]]></description>
										<content:encoded><![CDATA[<pre class="EnlighterJSRAW" data-enlighter-language="sql">DECLARE @Stmt NVARCHAR(MAX)

SET @Stmt = ''

SELECT  @Stmt = @Stmt + 'DROP FUNCTION [' + s.name + '].[' + o.name + '];' 
FROM sys.objects o
	INNER JOIN sys.schemas s ON s.schema_id = o.schema_id
WHERE type_desc LIKE '%FUNCTION%'

EXECUTE (@Stmt)
GO

SELECT * FROM sys.objects WHERE type_desc LIKE '%FUNCTION%'
GO</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
