<?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>Helpers &#8211; SQLpowered.com</title>
	<atom:link href="https://sqlpowered.com/script-category/helpers/feed/" rel="self" type="application/rss+xml" />
	<link>https://sqlpowered.com</link>
	<description>SQL Server + BI</description>
	<lastBuildDate>Mon, 14 Oct 2024 07:45:06 +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>Helpers &#8211; SQLpowered.com</title>
	<link>https://sqlpowered.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Export Large Query Result to File (PowerShell)</title>
		<link>https://sqlpowered.com/script/export-large-query-result-to-file-powershell/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Mon, 14 Oct 2024 07:45:06 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=5719</guid>

					<description><![CDATA[Export query output to file using PowerShell. Suitable for scenarios when large result set or single column value cannot be exported using SSMS. $query = "SELECT 1 AS COL1" $connectionString = "Server=***;Database=***;Integrated Security=false;User=***;Password=***" $outputFile = "/***/export.json" $connection = New-Object System.Data.SqlClient.SqlConnection $connection.ConnectionString = $connectionString $command = $connection.CreateCommand() $command.CommandText = $query $command.CommandTimeout...]]></description>
										<content:encoded><![CDATA[<p>Export query output to file using PowerShell. Suitable for scenarios when large result set or single column value cannot be exported using SSMS.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="powershell">$query = "SELECT 1 AS COL1"

$connectionString = "Server=***;Database=***;Integrated Security=false;User=***;Password=***"

$outputFile = "/***/export.json"

$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$command = $connection.CreateCommand()
$command.CommandText = $query
$command.CommandTimeout = 500

$connection.Open()
$reader = $command.ExecuteReader()

$results = @()
while ($reader.Read()) {
    $results += $reader["COL1"]
}

$connection.Close()

$results | Out-File -FilePath $outputFile -Encoding UTF8</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Tally Table</title>
		<link>https://sqlpowered.com/script/tally-table/</link>
		
		<dc:creator><![CDATA[Jan Dvořák]]></dc:creator>
		<pubDate>Tue, 11 Jan 2022 07:38:26 +0000</pubDate>
				<guid isPermaLink="false">https://sqlpowered.com/?post_type=script&#038;p=5344</guid>

					<description><![CDATA[Create Tally table and generate 100 million numbers. Change the CROSS JOIN part to limit the number of values generated. CREATE TABLE [Tally] ( [N] [INT] NOT NULL PRIMARY KEY ) GO ;WITH cte(N) AS ( SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) a (n) CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))...]]></description>
										<content:encoded><![CDATA[<p>Create Tally table and generate 100 million numbers. Change the CROSS JOIN part to limit the number of values generated.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="sql">CREATE TABLE [Tally] ( [N] [INT] NOT NULL PRIMARY KEY )
GO

;WITH cte(N) AS
(
	SELECT 
		ROW_NUMBER() OVER (ORDER BY (SELECT NULL))
	FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) a (n)
			CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) b (n)
			CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) c (n)
			CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) d (n)
			CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) e (n)
			CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) f (n)
			CROSS JOIN (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) g (n)
)
INSERT INTO [Tally] (N)
SELECT N
FROM cte
ORDER BY 1
GO</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
