Skip to content

Commit e506676

Browse files
committed
- Support for datetimeoffset type (#20)
- Config data types to not be scripted (#20) - Fixed SQL reading structure of a table (#23) - Do not script calculated columns (#18)
1 parent 7de9ddc commit e506676

6 files changed

+40
-12
lines changed

App.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<appSettings>
4-
<add key="excludeDataTypes" value="timestamp;datetimeoffset" />
4+
<add key="excludeDataTypes" value="timestamp;" />
55
</appSettings>
66
<startup>
77
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>

ChangesLog.txt

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
SQLPlayer Data Script Writer - Changes Log
22
==========================================
33

4+
ver.2.4 @ 08/09/2021
5+
- Support for datetimeoffset type (#20)
6+
- Config data types to not be scripted (#20)
7+
- Fixed SQL reading structure of a table (#23)
8+
- Do not script calculated columns (#18)
9+
- Option to open target folder in Explorer
10+
411
ver.2.3 @ 02/12/2020
512
- Support for Temporal tables (#10)
613
- Support for Time data type (#14)

Properties/Resources.Designer.cs

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Properties/Resources.resx

+9-6
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ INNER JOIN sys.schemas s on s.schema_id = o.schema_id
153153
WHERE o.name = parsename(@TableName, 1) and s.name = parsename(@TableName, 2)
154154
);
155155
WITH cc as (
156-
SELECT c.name as COLUMN_NAME, c.is_identity from sys.objects o
156+
SELECT c.name as COLUMN_NAME, c.is_identity, c.is_computed
157+
FROM sys.objects o
157158
INNER JOIN sys.columns c ON c.object_id = o.object_id
158159
WHERE o.object_id = @oid
159160
)
@@ -172,7 +173,8 @@ LEFT JOIN (
172173
) as co on co.TABLE_SCHEMA = c.TABLE_SCHEMA and co.TABLE_NAME = c.TABLE_NAME and co.COLUMN_NAME = c.COLUMN_NAME
173174
LEFT JOIN cc ON cc.COLUMN_NAME = c.COLUMN_NAME
174175
where c.table_name = parsename(@TableName, 1) and
175-
c.table_schema = parsename(@TableName, 2) ;</value>
176+
c.table_schema = parsename(@TableName, 2)
177+
and cc.is_computed = 0</value>
176178
</data>
177179
<data name="LoadColumnInfo2016andLater" xml:space="preserve">
178180
<value>DECLARE @Tablename nvarchar(100) = '{0}';
@@ -182,7 +184,7 @@ INNER JOIN sys.schemas s on s.schema_id = o.schema_id
182184
WHERE o.name = parsename(@TableName, 1) and s.name = parsename(@TableName, 2)
183185
);
184186
WITH cc as (
185-
SELECT c.name as COLUMN_NAME, c.is_identity, c.generated_always_type
187+
SELECT c.name as COLUMN_NAME, c.is_identity, c.generated_always_type, c.is_computed
186188
from sys.objects o
187189
INNER JOIN sys.columns c ON c.object_id = o.object_id
188190
WHERE o.object_id = @oid
@@ -202,7 +204,8 @@ LEFT JOIN (
202204
) as co on co.TABLE_SCHEMA = c.TABLE_SCHEMA and co.TABLE_NAME = c.TABLE_NAME and co.COLUMN_NAME = c.COLUMN_NAME
203205
LEFT JOIN cc ON cc.COLUMN_NAME = c.COLUMN_NAME
204206
where c.table_name = parsename(@TableName, 1)
205-
and c.table_schema = parsename(@TableName, 2)
206-
and cc.generated_always_type = 0</value>
207+
and c.table_schema = parsename(@TableName, 2)
208+
and cc.generated_always_type = 0
209+
and cc.is_computed = 0</value>
207210
</data>
208-
</root>
211+
</root>

ScriptWriter.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ private StringBuilder SerializeRowValues(DataRow row, DataTable colInfoTable, st
188188
case "binary":
189189
case "varbinary":
190190
v = "0x" + ByteArrayToHex((byte[])row[col]);
191-
break;
191+
break;
192+
case "datetimeoffset":
193+
v = String.Format("'{0:yyyyMMdd HH:mm:ss.fffffff} {1}'", row[col], row[col].ToString().Substring(row[col].ToString().Length - 6));
194+
break;
192195
default:
193196
throw new Exception("Unknown SQL data type! (" + sqltype + ")");
194197
}
@@ -448,6 +451,15 @@ private void ScriptTableInitialInsert(ScriptObject so, DataTable colInfoTable, D
448451
}
449452

450453

454+
public string OutputFolder
455+
{
456+
get
457+
{
458+
return _OutputFolder;
459+
}
460+
}
461+
462+
451463
public string UserName {
452464
get
453465
{

frmMain.cs

+5
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ private void bbiScript_ItemClick(object sender, DevExpress.XtraBars.ItemClickEve
7474
cnt++;
7575
}
7676
barStaticItem1.Caption = String.Format("Done. {0} tables were scripted.", cnt);
77+
DialogResult r = MessageBox.Show( "Do you want to open target location with File Explorer?", "Open target location", MessageBoxButtons.YesNo);
78+
if (r == DialogResult.Yes)
79+
{
80+
Process.Start("explorer.exe", _gen.OutputFolder);
81+
}
7782
}
7883

7984
private void gridControl1_DoubleClick(object sender, EventArgs e)

0 commit comments

Comments
 (0)