I made some library and want to use it as CLR assembly in MSSQL. The point is that my lib have the reference to 'iAnywhere.Data.SQLAnywhere' lib which I cannot install. The error is:
Assembly
'iAnywhere.Data.SQLAnywhere' could not be installed because existing
policy would keep it from being used.
I have implemented the recommendations and now my SQL looks like:
USE DB_Control
GO
ALTER DATABASE DB_Control SET TRUSTWORTHY ON WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE DB_Control SET TRUSTWORTHY ON
GO
exec sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
exec sp_configure 'clr enabled', 1;
GO
RECONFIGURE;
GO
CREATE ASSEMBLY [iAnywhere.Data.SQLAnywhere]
AUTHORIZATION sa
FROM '~\Debug\iAnywhere.Data.SQLAnywhere.dll'
WITH PERMISSION_SET = UNSAFE
GO
CREATE ASSEMBLY ClrSqlMediator
AUTHORIZATION sa
FROM '~\Debug\SQLMediator.dll'
WITH PERMISSION_SET = UNSAFE
GO
Does anybody know how to fix this?
Upd: Server version is SQL Server 2008 R2 (x64).
My MediatorCLR built as x64 lib, but I almost shure SQLAnywhere.dll built as x86. Can it be the reason?
Upd2: Here is Dropbox link to libs:
x64 - https,
x86 - https.
Upd3: I start thinking that SQLAnywhere.dll cannot be loaded at all because of x86 build option and I'm not sure that it has public static methods that is required. Surely i got to implement some other kind of reference.
Pay attention to there clauses
FROM '~\Debug\iAnywhere.Data.SQLAnywhere.dll'
FROM '~\Debug\SQLMediator.dll'
Here you should specify a valid path from SQL Server machine, after you have copied that .dll on SQL Server machine.
Alternatively, in case you don't have access to SQL Server file system in order to copy your assembly file, you can generate hex code, then register .NET assembly:
CREATE ASSEMBLY <AssemblyName.dll>
AUTHORIZATION [dbo]
FROM <0x4D5A9000030000000400000.... generated hex code here>
WITH PERMISSION_SET = SAFE
GO
Related
I am trying to importing a .bacpac of Azure DB into a locally running SQL Server 2017 Enterprise edition.
SQL Server is throwing the following error. I wonder if somebody could help. Thank you in advance.
Could not import package.
Warning SQL72012: The object [xxxxenter image description here-insights_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [2pointb-testing-insights_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: .Net SqlClient Data Provider:
Msg 10343, Level 14, State 1, Line 1
CREATE or ALTER ASSEMBLY for assembly 'GroupConcat' with the SAFE or EXTERNAL_ACCESS option failed because the 'clr strict security' option of sp_configure is set to 1. Microsoft recommends that you sign the assembly with a certificate or asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission. Alternatively, you can trust the assembly using sp_add_trusted_assembly.
Error SQL72045: Script execution error. The executed script:
CREATE ASSEMBLY [GroupConcat]
AUTHORIZATION [dbo]
FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C01030058898C510000000000000000E00002210B010B00001E000000080000000000007E3D0000002000000040000000000010002000000002000004000000000000000400000000000000008000000002000000000000030040850000100000100000000010000010000000000000100000000000000000000000243D000057000000004000003804000000000000000000000000000000000000006000000C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E74657874000000841D000000200000001E000000020000000000000000000000000000200000602E7273726300000038040000004000000006000000200000000000000000000000000000400000402E72656C6F6300000C000000006000000002000000260
(Microsoft.SqlServer.Dac)
The following script worked for me:
EXEC sp_configure 'show advanced options',1;
GO
RECONFIGURE;
GO
EXEC sp_configure 'clr strict security',0;
GO
RECONFIGURE;
GO
i am trying to open a .exe file from within an sql query or Job.
im using xp_cmdshell , it is enabled on the server
the .exe runs properly when i double click on it from my windows Explorer
but when i try to open it using xp_cmdshell it returns to me 1 row affected
and the row is null.
the .exe file is supposed to delete all the content from a certain table.
when i run the file from the windows explorer, the .exe deletes all the content of the above mentioned table, whereas when i try using xp_cmdshell the content of the table remain intact, which means the .exe file is not opened.
any ideas?? this is the code i'm using
exec master..xp_cmdshell 'C:\inetpub\wwwroot\Digital_Library_Shamaa\ShamaaConsoleIndexer\Publish\setup.exe'
i have added the permission Everyone to the folder containing the above .exe file and all its sub folders!
1) Run EXEC master..xp_cmdshell 'whoami' to see which user you're trying to run the exe file
2) Did you enable :
USE master
GO
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE WITH OVERRIDE
GO
3) Did you unblock the file ?
We are trying to deploy a database project using tfs deployer and "vsdbcmd.exe" (VS 2010 version).
Both are on a windows server 2008 r2 (64 bit).
When our deployment script runs and we call the VSDBCMD.exe, we get the following error:
An unexpected failure occurred: Object reference not set to an instance of an object.
Note: SQL Server is not installed on this server, the script calls to a different server which has the databases we want to execute the database schemas against. Visual studio is also not installed on this server so I executed reg add HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0 as I found a missing registry key could be causing the issue. However, the problem still occurs
The dll's copied to the server are:
Extensions (folder)
DatabaseSchemaProviders.Extensions.xml
Microsoft.Data.Schema.dll
Microsoft.Data.Schema.ScriptDom.dll
Microsoft.Data.Schema.ScriptDom.Sql.dll
Microsoft.Data.Schema.Sql.dll
Microsoft.Data.Schema.Utilities.dll
Sqlceer35en.dll
Sqlceme35.dll
Sqlceqp35.dll
Sqlcese35.dll
sqlceca35.dll
sqlcecompact35.dll
sqlceoledb35.dll
System.Data.SqlServerCe.dll
vsdbcmd.exe
vsdbcmd.exe.config
Any ideas on how to resolve this would be great
Thanks,
Ryan
I'm creating an install package using InnoSetup and installing SQL Server 2005 Express. Here's the code below that appears in my RUN section:
Filename: "{app}\SQL Server 2005 Express\SQLEXPR.exe" ; Parameters: "-q /norebootchk /qn reboot=ReallySuppress addlocal=all INSTANCENAME=(LOCAL) SCCCHECKLEVEL=IncompatibleComponents:1;MDAC25Version:0 ERRORREPORTING=2 SQLAUTOSTART=1 SAPWD=passwordhere SECURITYMODE=SQL"; WorkingDir: {app}\SQL Server 2005 Express; StatusMsg: Installing Microsoft SQL Server 2005 Express... Please Wait...;Check:SQLVerifyInstall
What I'm trying to accomplish is have the SQL Server package install but only have the instance name itself reference the name of the machine name and nothing more. What I'm receiving instead is a named instance instead of local such as MachineName\SQLEXPRESS which is not what I want to receive.
I need a local instance instead of a named instance due to the way my code is written to be able to install and talk with the databases in question. I would change it, trust me, were it not the fact that this install package is a replacement to a previous package that used the MSDE installer. I have to be able to support both through code. Any suggestions are welcome but a clear and concise method to get the installer to quietly install using only the machine name is my main goal. Thanks for the help and support!
Here's a sample for setting the InstanceName in code:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{4D044938-6185-4729-8EB9-33CFA5D51993}
AppName=My Program
AppVerName=My Program 1.5
AppPublisher=My Company, Inc.
AppPublisherURL=http://www.example.com/
AppSupportURL=http://www.example.com/
AppUpdatesURL=http://www.example.com/
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
OutputBaseFilename = setup
Compression = lzma
SolidCompression = yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "SQLEXPR.exe"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Run]
Filename: "{app}\SQLEXPR.exe" ; Parameters: "INSTANCENAME={code:MyInstanceName|'SQLEXPRESS'}";
[Code]
function MyInstanceName(Param: String): String;
begin
//This sets the value to \MSSQLSERVER.
Result := ExpandConstant('{computername}') + '\MSSQLSERVER';
end;
However, from what I've seen on the net the instance name should be MSSQLSERVER if you want it to be the default instance on the machine.
I need to set up an instance of SQL Server 2005 with SQL_Latin1_General_CP850_Bin as the server collation (the vendor did not take into accounting looking at DB collation for a bunch of things so stored procedures and temp tables default to the server level and the default collation will not work). During the install for SQL Server it did not give that as an option so I left it at default and finished installing it.
According to MSDN and Technet I should need to just run the following command:
setup.exe /q /ACTION=RebuildDatabase /INSTANCENAME=MSSQLSERVER /SAPWD="sa-pwd" /SQLSYSADMINACCOUNTS="BUILTIN\ADMINISTRATORS" /SqlCollation=SQL_Latin1_General_CP1_CI_AI
However, whenever I run the above command with my parameters I get the pop-up of the SQL Server installation wizard, accept the agreement, and then it gives me output stating how to use the command.
Any idea what I can do?
I think you're looking at instructions for SQL Server 2008.
See the article here for instructions for 2005.
If possible, I would uninstall and reinstall rather than trying to change it. Changing it without re-installing is not a simple process. To change from the default during install, just uncheck the "Hide advanced configuration options" check box on the Registration Information screen; doing that will give you a Collation Settings option about 4 screens later in the install.