Skip to content

Commit b95d377

Browse files
committed
Changed to use SQLNCLI11 instead of SQLNCLI10
1 parent c8f5df5 commit b95d377

9 files changed

Lines changed: 73 additions & 9 deletions

Packages/d103/sqlcmdcli.dpr

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ uses
2525
sqlcmdcli.StressDB in '..\..\Sources\sqlcmdcli.StressDB.pas',
2626
sqlcmdcli.SchemaExtractor in '..\..\Sources\sqlcmdcli.SchemaExtractor.pas',
2727
sqlcmdcli.AnonymizeDB in '..\..\Sources\sqlcmdcli.AnonymizeDB.pas',
28-
sqlcmdcli.AlterColumn in '..\..\Sources\sqlcmdcli.AlterColumn.pas';
28+
sqlcmdcli.AlterColumn in '..\..\Sources\sqlcmdcli.AlterColumn.pas',
29+
sqlcmdcli.Constants in '..\..\Sources\sqlcmdcli.Constants.pas';
2930

3031
var
3132
LHeader: string;
@@ -40,6 +41,15 @@ begin
4041

4142
//TConsole.SetTitle('')
4243

44+
// Check SQL Server Native Client
45+
//if not TSQLUtils.CheckNativeClient(SQL_SERVER_NATIVE_CLIENT_11) then
46+
//begin
47+
// ExitCode := 1;
48+
// Writeln;
49+
// Writeln(Format(RS_ERROR_SQL_SERVER_NATIVE_CLIENT, [SQL_SERVER_NATIVE_CLIENT_11]));
50+
// Exit;
51+
//end;
52+
4353
// CLI Initialize
4454
TBootCLI.Boot;
4555

Packages/d103/sqlcmdcli.dproj

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@
112112
<VerInfo_Locale>1033</VerInfo_Locale>
113113
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
114114
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
115-
<VerInfo_Keys>CompanyName=;FileDescription=Command-line utility for ad hoc, interactive execution of commands on SQL Server;FileVersion=1.0.0.26;InternalName=sqlcmdcli;LegalCopyright=;LegalTrademarks=;OriginalFilename=sqlcmdcli.exe;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0;Comments=https://github.com/segovoni/sqlcmdcli</VerInfo_Keys>
116-
<VerInfo_Build>26</VerInfo_Build>
115+
<VerInfo_Keys>CompanyName=;FileDescription=Command-line utility for ad hoc, interactive execution of commands on SQL Server;FileVersion=1.0.0.52;InternalName=sqlcmdcli;LegalCopyright=;LegalTrademarks=;OriginalFilename=sqlcmdcli.exe;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0;Comments=https://github.com/segovoni/sqlcmdcli</VerInfo_Keys>
116+
<VerInfo_Build>52</VerInfo_Build>
117117
</PropertyGroup>
118118
<ItemGroup>
119119
<DelphiCompile Include="$(MainSource)">
@@ -136,6 +136,7 @@
136136
<DCCReference Include="..\..\Sources\sqlcmdcli.SchemaExtractor.pas"/>
137137
<DCCReference Include="..\..\Sources\sqlcmdcli.AnonymizeDB.pas"/>
138138
<DCCReference Include="..\..\Sources\sqlcmdcli.AlterColumn.pas"/>
139+
<DCCReference Include="..\..\Sources\sqlcmdcli.Constants.pas"/>
139140
<RcItem Include="..\..\Resources\sqlcmdcli.txt">
140141
<ContainerId>ResourceItem</ContainerId>
141142
<ResourceType>TEXT</ResourceType>
@@ -177,6 +178,18 @@
177178
<Overwrite>true</Overwrite>
178179
</Platform>
179180
</DeployFile>
181+
<DeployFile LocalName="..\..\Resources\sqlcmdcli.txt" Configuration="Debug" Class="ProjectFile">
182+
<Platform Name="Win32">
183+
<RemoteDir>.\</RemoteDir>
184+
<Overwrite>true</Overwrite>
185+
</Platform>
186+
</DeployFile>
187+
<DeployFile LocalName="Win32\Release\sqlcmdcli.exe" Configuration="Release" Class="ProjectOutput">
188+
<Platform Name="Win32">
189+
<RemoteName>sqlcmdcli.exe</RemoteName>
190+
<Overwrite>true</Overwrite>
191+
</Platform>
192+
</DeployFile>
180193
<DeployFile LocalName="$(BDS)\Redist\iossimulator\libcgunwind.1.0.dylib" Class="DependencyModule">
181194
<Platform Name="iOSSimulator">
182195
<Overwrite>true</Overwrite>
@@ -193,7 +206,13 @@
193206
<Overwrite>true</Overwrite>
194207
</Platform>
195208
</DeployFile>
196-
<DeployFile LocalName="..\..\Resources\sqlcmdcli.txt" Configuration="Debug" Class="ProjectFile">
209+
<DeployFile LocalName="..\..\Resources\sqlcmdcli.txt" Configuration="Release" Class="ProjectFile">
210+
<Platform Name="Win32">
211+
<RemoteDir>.\</RemoteDir>
212+
<Overwrite>true</Overwrite>
213+
</Platform>
214+
</DeployFile>
215+
<DeployFile LocalName="..\..\Libraries\sp_alter_column\source\sp-alter-column.sql" Configuration="Release" Class="ProjectFile">
197216
<Platform Name="Win32">
198217
<RemoteDir>.\</RemoteDir>
199218
<Overwrite>true</Overwrite>

Sources/sqlcmdcli.AlterColumn.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class procedure TAlterColumn.Run(const AServerName, ADatabaseName, AUserName,
4040
try // finally
4141
// ADO connection string
4242
LConnection.ConnectionString :=
43-
'Provider=SQLNCLI10.1;' +
43+
'Provider=SQLNCLI11;' +
4444
//'Integrated Security="";' +
4545
'Persist Security Info=False;' +
4646
//'User ID=' + AUserName + '@' + AServerName + ';' +

Sources/sqlcmdcli.AnonymizeDB.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class procedure TAnonymizeDB.Run(const AServerName, ADatabaseName, AUserName,
201201
try // finally
202202
// ADO connection string
203203
LConnection.ConnectionString :=
204-
'Provider=SQLNCLI10.1;' +
204+
'Provider=SQLNCLI11;' +
205205
//'Integrated Security="";' +
206206
'Persist Security Info=False;' +
207207
//'User ID=' + AUserName + '@' + AServerName + ';' +

Sources/sqlcmdcli.Constants.pas

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
unit sqlcmdcli.Constants;
2+
3+
interface
4+
5+
const
6+
SQL_SERVER_NATIVE_CLIENT_10 = 'SQLNCLI10';
7+
SQL_SERVER_NATIVE_CLIENT_11 = 'SQLNCLI11';
8+
SQL_SERVER_NATIVE_CLIENT_12 = 'SQLNCLI12';
9+
10+
implementation
11+
12+
end.

Sources/sqlcmdcli.QueryStore.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class procedure TQueryStoreWorkload.Run(const AServerName, ADatabaseName, AUserN
6464

6565
// ADO
6666
LConnection.ConnectionString :=
67-
'Provider=SQLNCLI10.1;' +
67+
'Provider=SQLNCLI11;' +
6868
//'Integrated Security="";' +
6969
'Persist Security Info=False;' +
7070
//'User ID=' + AUserName + '@' + AServerName + ';' +

Sources/sqlcmdcli.ResourceStrings.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ interface
7272
RS_STATUS_MSG = #13'Processing %d of %d (%d%%)... ';
7373
RS_QRY_QUERYSTORE_REGRESSION = 'SELECT * FROM dbo.#Tab_A WHERE (Col1 = %d) AND (Col2 = %d)';
7474

75+
RS_ERROR_SQL_SERVER_NATIVE_CLIENT = 'SQL Server Native Client %s is not installed! ' +
76+
'Check here to know how to install SQL ' +
77+
'Server Native Client: https://bit.ly/3wFVJXz';
78+
7579
implementation
7680

7781
end.

Sources/sqlcmdcli.StressDB.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class procedure TStressDB.Run(const AServerName, ADatabaseName, AUserName,
4141
try
4242
// ADO connection string
4343
LConnection.ConnectionString :=
44-
'Provider=SQLNCLI10.1;' +
44+
'Provider=SQLNCLI11;' +
4545
//'Integrated Security="";' +
4646
'Persist Security Info=False;' +
4747
//'User ID=' + AUserName + '@' + AServerName + ';' +

Sources/sqlcmdcli.Utils.pas

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ TSQLUtils = class(TObject)
3030
class procedure SQLCharacterMaskFactory(AConnection: TADOConnection);
3131
class procedure SQLStringReverseFnFactory(AConnection: TADOConnection);
3232
class procedure SQLStringScramblerFnFactory(AConnection: TADOConnection);
33+
class function CheckNativeClient(const AVersion: string): Boolean;
3334
end;
3435

3536
implementation
3637

3738
uses
3839
System.Classes
3940
,System.SysUtils
40-
,System.StrUtils;
41+
,System.StrUtils
42+
,System.Win.Registry
43+
,Winapi.Windows;
4144

4245
{ TResourceUtils }
4346

@@ -304,6 +307,22 @@ class function TSQLUtils.GetStateTriggerStatements(AConnection: TADOConnection;
304307
end;
305308
end;
306309

310+
class function TSQLUtils.CheckNativeClient(const AVersion: string): Boolean;
311+
var
312+
LRegistry: TRegistry;
313+
begin
314+
Result := False;
315+
LRegistry := TRegistry.Create(KEY_READ);
316+
try
317+
LRegistry.RootKey := HKEY_LOCAL_MACHINE;
318+
// SOFTWARE\Microsoft\Microsoft SQL Server\SQLNCLI11\CurrentVersion
319+
if (LRegistry.KeyExists('\SOFTWARE\Microsoft\Microsoft SQL Server\' + AVersion {SQLNCLI11} + '\CurrentVersion\')) then
320+
Result := True;
321+
finally
322+
FreeAndNil(LRegistry);
323+
end;
324+
end;
325+
307326
class function TSQLUtils.GetCheckConstraintOnTextColumns(
308327
AConnection: TADOConnection): TDictionary<string, string>;
309328
var

0 commit comments

Comments
 (0)