├── .gitattributes
├── .gitignore
├── ArchivedPatchNotes.md
├── Chocolatey
├── TSQLFlex.nuspec
└── tools
│ ├── chocolateyInstall.ps1
│ └── chocolateyUninstall.ps1
├── Code
├── TSqlFlex.Core.Tests
│ ├── CSVRendererTests.cs
│ ├── CSharpRenderTests.cs
│ ├── DataScriptingTests.cs
│ ├── ExcelLauncherTests.cs
│ ├── FlexResultSetTests.cs
│ ├── InternationalTests.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── QueryRunnerTests.cs
│ ├── RegistryTests.cs
│ ├── SchemaScriptingTests.cs
│ ├── TSqlFlex.Core.Tests.csproj
│ ├── TSqlRulesTests.cs
│ ├── XmlSpreadsheetRenderTests.cs
│ └── packages.config
├── TSqlFlex.Core
│ ├── CSVRenderer.cs
│ ├── CSharpRenderer.cs
│ ├── Config.cs
│ ├── CustomExceptions.cs
│ ├── ExcelLauncher.cs
│ ├── ExternalProgramLauncher.cs
│ ├── FieldScripting.cs
│ ├── FlexResult.cs
│ ├── FlexResultSet.cs
│ ├── Logging.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── QueryWorker.cs
│ ├── Resources
│ │ └── XMLSpreadsheetTemplateHeader.txt
│ ├── SQLColumn.cs
│ ├── SqlRunParameters.cs
│ ├── TSqlFlex.Core.csproj
│ ├── TSqlRules.cs
│ ├── TxtLauncher.cs
│ ├── Utils.cs
│ └── XmlSpreadsheetRenderer.cs
├── TSqlFlex.sln
├── TSqlFlex
│ ├── AboutBox.Designer.cs
│ ├── AboutBox.cs
│ ├── AboutBox.resx
│ ├── Extension.cs
│ ├── FlexMainWindow.Designer.cs
│ ├── FlexMainWindow.cs
│ ├── FlexMainWindow.resx
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── RunCommand.cs
│ ├── TSqlFlex.csproj
│ └── packages.config
└── packages
│ └── repositories.config
├── Deploy
└── prepDeploy.ps1
├── InstallationInstructions.md
├── License.md
├── README.md
└── Resources
└── TSqlFlexScriptToInserts.gif
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Code/Packages/
2 | Deploy/Binaries/
3 |
4 | #################
5 | ## Eclipse
6 | #################
7 |
8 | *.pydevproject
9 | .project
10 | .metadata
11 | bin/
12 | tmp/
13 | *.tmp
14 | *.bak
15 | *.swp
16 | *~.nib
17 | local.properties
18 | .classpath
19 | .settings/
20 | .loadpath
21 |
22 | # External tool builders
23 | .externalToolBuilders/
24 |
25 | # Locally stored "Eclipse launch configurations"
26 | *.launch
27 |
28 | # CDT-specific
29 | .cproject
30 |
31 | # PDT-specific
32 | .buildpath
33 |
34 |
35 | #################
36 | ## Visual Studio
37 | #################
38 |
39 | ## Ignore Visual Studio temporary files, build results, and
40 | ## files generated by popular Visual Studio add-ons.
41 |
42 | # User-specific files
43 | *.suo
44 | *.user
45 | *.sln.docstates
46 |
47 | .vs/
48 |
49 | # Build results
50 |
51 | [Dd]ebug/
52 | [Rr]elease/
53 | x64/
54 | build/
55 | [Bb]in/
56 | [Oo]bj/
57 |
58 | # MSTest test Results
59 | [Tt]est[Rr]esult*/
60 | [Bb]uild[Ll]og.*
61 |
62 | *_i.c
63 | *_p.c
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.pch
68 | *.pdb
69 | *.pgc
70 | *.pgd
71 | *.rsp
72 | *.sbr
73 | *.tlb
74 | *.tli
75 | *.tlh
76 | *.tmp
77 | *.tmp_proj
78 | *.log
79 | *.vspscc
80 | *.vssscc
81 | .builds
82 | *.pidb
83 | *.log
84 | *.scc
85 |
86 | # Visual C++ cache files
87 | ipch/
88 | *.aps
89 | *.ncb
90 | *.opensdf
91 | *.sdf
92 | *.cachefile
93 |
94 | # Visual Studio profiler
95 | *.psess
96 | *.vsp
97 | *.vspx
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | *.ncrunch*
114 | .*crunch*.local.xml
115 |
116 | # Installshield output folder
117 | [Ee]xpress/
118 |
119 | # DocProject is a documentation generator add-in
120 | DocProject/buildhelp/
121 | DocProject/Help/*.HxT
122 | DocProject/Help/*.HxC
123 | DocProject/Help/*.hhc
124 | DocProject/Help/*.hhk
125 | DocProject/Help/*.hhp
126 | DocProject/Help/Html2
127 | DocProject/Help/html
128 |
129 | # Click-Once directory
130 | publish/
131 |
132 | # Publish Web Output
133 | *.Publish.xml
134 | *.pubxml
135 |
136 | # NuGet Packages Directory
137 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
138 | #packages/
139 |
140 | # Windows Azure Build Output
141 | csx
142 | *.build.csdef
143 |
144 | # Windows Store app package directory
145 | AppPackages/
146 |
147 | # Others
148 | sql/
149 | *.Cache
150 | ClientBin/
151 | [Ss]tyle[Cc]op.*
152 | ~$*
153 | *~
154 | *.dbmdl
155 | *.[Pp]ublish.xml
156 | *.pfx
157 | *.publishsettings
158 |
159 | # RIA/Silverlight projects
160 | Generated_Code/
161 |
162 | # Backup & report files from converting an old project file to a newer
163 | # Visual Studio version. Backup files are not needed, because we have git ;-)
164 | _UpgradeReport_Files/
165 | Backup*/
166 | UpgradeLog*.XML
167 | UpgradeLog*.htm
168 |
169 | # SQL Server files
170 | App_Data/*.mdf
171 | App_Data/*.ldf
172 |
173 | #############
174 | ## Windows detritus
175 | #############
176 |
177 | # Windows image file caches
178 | Thumbs.db
179 | ehthumbs.db
180 |
181 | # Folder config file
182 | Desktop.ini
183 |
184 | # Recycle Bin used on file shares
185 | $RECYCLE.BIN/
186 |
187 | # Mac crap
188 | .DS_Store
189 |
190 |
191 | #############
192 | ## Python
193 | #############
194 |
195 | *.py[co]
196 |
197 | # Packages
198 | *.egg
199 | *.egg-info
200 | dist/
201 | build/
202 | eggs/
203 | parts/
204 | var/
205 | sdist/
206 | develop-eggs/
207 | .installed.cfg
208 |
209 | # Installer logs
210 | pip-log.txt
211 |
212 | # Unit test / coverage reports
213 | .coverage
214 | .tox
215 |
216 | #Translations
217 | *.mo
218 |
219 | #Mr Developer
220 | .mr.developer.cfg
221 |
222 | Chocolatey/*.nupkg
--------------------------------------------------------------------------------
/ArchivedPatchNotes.md:
--------------------------------------------------------------------------------
1 |
2 | **Archived patch notes:**
3 | * v0.0.11-alpha (2015-01-23):
4 | * Updated to use .NET 4.5 - this version is now required to run T-SQL Flex.
5 | * Improved scripter to continuously increment the "#Result" table number to prevent conflicts in a session.
6 | * Fixed lockup of SSMS when switching between database servers. (#33)
7 | * Fixed missing column header for anonymous columns in Excel export (#29)
8 | * Added WEIGHT, TARGET, and NONE as T-SQL keywords.
9 | * Implemented improved logging.
10 | * v0.0.10-alpha (2014-09-11):
11 | * Implemented drag and drop of database objects from object explorer.
12 | * Fix for launching Excel exported files when there is a space in the profile path name.
13 | * Fix for scripting a field name that includes spaces without bracketizing it.
14 | * v0.0.9-alpha (2014-09-11):
15 | * Fix for "Invalid class string" exception in SSMS 2008 or lower (via pull request from David Pond - many thanks!)
16 | * Fix for "unable to determine identity of domain" isolated storage initialization bug in SSMS 2008 or lower.
17 | * Fixes for CTRL+A and CTRL+C - "Select all" and "copy" keyboard shortcuts now work as expected with T-SQL Flex.
18 | * Additional exception handling during data scripting - hopefully will allow more graceful recovery from out of memory exceptions, in particular.
19 | * Some clarifications to the installation instructions including mentioning that the user must unblock the DLLs.
20 | * Fixed the T-SQL Flex metadata so that the add-in info appears in the "SSMS Add-ins" dialog.
21 | * v0.0.8-alpha (2014-09-06):
22 | * Added about box with version info and links for feedback, issues, and updates.
23 | * Added button to open the latest scripted XML spreadsheet in Excel.
24 | * Fix for some rare cross-thread UI update issues.
25 | * v0.0.7-alpha (2014-09-02):
26 | * Significant bug fixes for internationalization issues surrounding time and number formatting including tests. Cultures where . is used as the time separator and , as a decimal point should work OK now for both Excel and SQL INSERT scripts. Special thanks to Gianluca Sartori (@SpaghettiDBA) for assistance with troubleshooting these issues.
27 | * Bug fixes for incorrect columns and commas appearing in INSERT scripts due to hidden fields.
28 | * Added more line-feeds to the scripted XML Spreadsheet 2003 output.
29 | * Finished refactoring to "format" functions (this is an internal change only).
30 | * v0.0.6-alpha (2014-08-30):
31 | * Significant improvements to exception handling during all phases of querying and scripting
32 | * Significant changes to disk-based buffering. Now uses .NET IsolatedStorage.
33 | * Significant refactoring - moved query processing logic from UI to Core DLL.
34 | * Fixed bug where synthetic columns (select 'a' as [z]) were incorrectly hidden.
35 | * Fixed bug with scripting binary and other byte[] data fields to Excel.
36 | * Updated SIP Framework to 1.0.1.243 (from July 2014).
37 | * v0.0.5-alpha (2014-08-22):
38 | * Export to "XML Spreadsheet 2003" functionality added - this is very early alpha for this feature.
39 | * Started significant refactoring effort for data scripting in T-SQL field vs general presentation.
40 | * Started work to use a file stream rather than a string builder for scripting the data. Currently only used with the Excel XML export.
41 | * v0.0.4-alpha (2014-06-18):
42 | * Converted to background worker. Added cancel button, timer, and progress bar.
43 | * Additional scripted output "minification" improvements (dropping insignificant decimals for example).
44 | * Other improvements to quality of scripted output such as bracketing of keywords.
45 | * v0.0.3-alpha (2014-06-13): Fixed data script escaping bug for single quotes.
46 | * v0.0.2-alpha (2014-06-11): Data scripting implemented. Improved window.
47 | * v0.0.1-alpha (2014-06-01): Initial release. Schema scripting working.
48 |
--------------------------------------------------------------------------------
/Chocolatey/TSQLFlex.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | tsqlflex
6 | T-SQL Flex
7 | 0.2.1-beta
8 | Steve Ognibene
9 | NYCdotNet
10 | SSMS add-in for scripting and Excel export.
11 | SSMS add-in for scripting and Excel export.
12 | https://github.com/nycdotnet/TSqlFlex
13 | T-SQL Flex SQL Server SSMS
14 | 2017
15 | https://github.com/nycdotnet/TSqlFlex/blob/master/License.md
16 | false
17 |
18 |
19 |
20 |
21 | * v0.2.1-beta (2016-07-13):
22 | * Fixed scripting of TIME to XML Spreadsheet (no longer crashes)
23 | * Improved scripting of TIME to SQL scripts - can include up to 7 digits of scale.
24 | * Improved scripting of DATETIME2 to SQL scripts - now includes scale number if relevant.
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Chocolatey/tools/chocolateyInstall.ps1:
--------------------------------------------------------------------------------
1 | $packageName = "T-SQL Flex";
2 | $url = "https://github.com/nycdotnet/TSqlFlex/releases/download/0.2.1-beta/TSqlFlex-0.2.1-beta.zip";
3 | $installLocation = "$env:ProgramData\T-SQL Flex";
4 |
5 | Install-ChocolateyZipPackage "$packageName" "$url" "$installLocation"
6 |
7 | function Create-RegistryKeyIfNotExists($parentKey, $testKey) {
8 | if ((test-path "$parentKey\$testKey") -eq $false) {
9 | New-Item -Path "$parentKey" -Name "$testKey" | Out-Null
10 | }
11 | if ((test-path "$parentKey\$testKey") -eq $true) {
12 | return "$parentKey\$testKey";
13 | }
14 | throw "unable to create or confirm existence of '$parentKey\$testKey'";
15 | }
16 |
17 | # thanks: http://stackoverflow.com/questions/5648931/test-if-registry-value-exists
18 | function Test-RegistryValue($regkey, $name) {
19 | $exists = Get-ItemProperty -Path "$regkey" -Name "$name" -ErrorAction SilentlyContinue
20 | If (($exists -ne $null) -and ($exists.Length -ne 0)) {
21 | Return $true
22 | }
23 | Return $false
24 | }
25 |
26 | function Get-RegistrySoftwareRootKey() {
27 | if (Get-ProcessorBits -eq 64) {
28 | Write-Debug "64-bit processor detected.";
29 | Return "HKLM:\Software\Wow6432Node";
30 | }
31 | Write-Debug "32-bit processor detected.";
32 | Return "HKLM:\Software";
33 | }
34 |
35 |
36 | $root = Get-RegistrySoftwareRootKey;
37 | $createdKey = $root;
38 | $addKeys = "Red Gate\SIPFramework\Plugins";
39 | $addKeys.Split("\") | % { $createdKey = Create-RegistryKeyIfNotExists $createdKey $_ }
40 |
41 | if ((Test-RegistryValue $createdKey "TSQLFlex") -eq $false) {
42 | New-ItemProperty -Name "TSQLFlex" -Path $createdKey -Value "$installLocation\TSqlFlex.dll" | Out-Null
43 | } else {
44 | Set-ItemProperty -Name "TSQLFlex" -Path $createdKey -Value "$installLocation\TSqlFlex.dll" | Out-Null
45 | }
46 |
--------------------------------------------------------------------------------
/Chocolatey/tools/chocolateyUninstall.ps1:
--------------------------------------------------------------------------------
1 | $packageName = "T-SQL Flex";
2 | $installLocation = "$env:ProgramData\T-SQL Flex";
3 |
4 | function Remove-ItemIfExists($itemName) {
5 | if ((Test-Path $itemName) -eq $true) {
6 | Remove-Item $itemName;
7 | }
8 | }
9 |
10 | # thanks: http://stackoverflow.com/questions/5648931/test-if-registry-value-exists
11 | function Test-RegistryValue($regkey, $name) {
12 | $exists = Get-ItemProperty -Path "$regkey" -Name "$name" -ErrorAction SilentlyContinue
13 | If (($exists -ne $null) -and ($exists.Length -ne 0)) {
14 | Return $true
15 | }
16 | Return $false
17 | }
18 |
19 | function Get-RegistrySoftwareRootKey() {
20 | if (Get-ProcessorBits -eq 64) {
21 | Return "HKLM:\Software\Wow6432Node";
22 | }
23 | Return "HKLM:\Software";
24 | }
25 |
26 | Remove-ItemIfExists "$installLocation\RedGate.SIPFrameworkShared.dll";
27 | Remove-ItemIfExists "$installLocation\TSqlFlex.Core.dll";
28 | Remove-ItemIfExists "$installLocation\TSqlFlex.dll";
29 | Remove-ItemIfExists "$installLocation\InstallationInstructions.txt";
30 | Remove-ItemIfExists "$installLocation\License.txt";
31 | Remove-ItemIfExists "$installLocation\README.txt";
32 |
33 | $root = Get-RegistrySoftwareRootKey;
34 | $pluginsPath = "$root\Red Gate\SIPFramework\Plugins";
35 | if ((Test-RegistryValue $pluginsPath "TSQLFlex") -eq $true) {
36 | Remove-ItemProperty -Name "TSQLFlex" -Path $pluginsPath | Out-Null
37 | }
38 |
39 | try {
40 | Remove-ItemIfExists "$installLocation";
41 | } catch {
42 | # Don't sweat it.
43 | }
44 |
--------------------------------------------------------------------------------
/Code/TSqlFlex.Core.Tests/CSVRendererTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading;
7 | using NUnit.Framework;
8 |
9 | namespace TSqlFlex.Core.Tests
10 | {
11 | [TestFixture()]
12 | class CSVRendererTests
13 | {
14 | [Test()]
15 | public void string_with_no_commas_is_not_enclosed()
16 | {
17 | string testit = "This is a test";
18 | Assert.AreEqual(testit, TSqlFlex.Core.CSVRenderer.escapeForCSV(testit));
19 | }
20 |
21 | [Test()]
22 | public void string_with_commas_is_enclosed()
23 | {
24 | string testit = "Developer, Jane Q.";
25 | Assert.AreEqual("\"" + testit + "\"", TSqlFlex.Core.CSVRenderer.escapeForCSV(testit));
26 | }
27 |
28 | [Test()]
29 | public void string_starting_with_zero_is_enclosed()
30 | {
31 | string testit = "00000000";
32 | Assert.AreEqual("\"" + testit + "\"", TSqlFlex.Core.CSVRenderer.escapeForCSV(testit));
33 | }
34 |
35 | [Test()]
36 | public void string_starting_with_numeric_nonzero_is_not_enclosed()
37 | {
38 | string testit = "10000000";
39 | Assert.AreEqual(testit, TSqlFlex.Core.CSVRenderer.escapeForCSV(testit));
40 | }
41 |
42 | [Test()]
43 | public void string_that_is_lone_zero_is_not_enclosed()
44 | {
45 | string testit = "0";
46 | Assert.AreEqual(testit, TSqlFlex.Core.CSVRenderer.escapeForCSV(testit));
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Code/TSqlFlex.Core.Tests/CSharpRenderTests.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Data.SqlClient;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace TSqlFlex.Core.Tests
9 | {
10 | [TestFixture()]
11 | class CSharpRenderTests
12 | {
13 | [Test()]
14 | public void two_simple_columns_returns_valid_class()
15 | {
16 | var resultSet = new FlexResultSet();
17 | var result = new FlexResult();
18 | result.schema = new List() {
19 | new SQLColumn() { ColumnName = "testa", DataType = "int" },
20 | new SQLColumn() { ColumnName = "testb", DataType = "varchar" }
21 | };
22 | result.data = new List