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
Related
I'm trying to attach a database to Microsoft SQL Server Management Studio. I have moved the .MDF file into C:\programfiles\Microsoft SQL Server\MSSQL11.MSSQLEXPRESS\MSSQL\Data
It shows up when I go to the attach screen but I get this error message when I hit 'OK' on the attach screen:
Attach database failed for Server 'DESKTOP-5DHLE7T\sqlexpress'.
(Microsoft.SqlServer.Smo)
Additional information:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Directory lookup for the file "C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_Log.ldf" failed with the operating system error 3 (The system cannot find the path specified.). (Microsoft SQL Server, Error: 5133)
My instructions say to attach the database to C:\programfiles\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data . However despite completing the exact same installation as the guide I don't have a MSSQL11.MSSQLSERVER path, only the C:\programfiles\Microsoft SQL Server\MSSQL11.MSSQLEXPRESS\MSSQL\Data like I stated earlier.
Is this where my problem lies? If so, where should I be putting the .MDF file before I attach it? Any ideas will be much appreciated
First of all, you are attaching the files to your database server, not Management Studio.
Second, your error is about a log file missing. You actually donĀ“t need the LDF just to attach the file, but you need to do some work to make it happen:
USE [master] GO
-- Method 1: I use this method
EXEC sp_attach_single_file_db #dbname='TestDb',
#physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\YourDBFile.mdf'
GO
Or, you can also do this:
CREATE DATABASE TestDb ON
(FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\YourDBFile.mdf')
FOR ATTACH_REBUILD_LOG
GO
The error message is saying the LDF file is missing. You need both the MDF and the LDF.
You can click the second file with type is LDF and hit "Remove"
Trying to execute the test script that MSDN provides to make sure R is enabled, but it throws the following error,
Msg 39023, Level 16, State 1, Procedure sp_execute_external_script, Line 1 [Batch Start Line 0]
'sp_execute_external_script' is disabled on this instance of SQL Server. Use sp_configure 'external scripts enabled' to enable it.
Msg 11536, Level 16, State 1, Line 1
EXECUTE statement failed because its WITH RESULT SETS clause specified 1 result set(s), but the statement only sent 0 result set(s) at run time.
I have made sure i run the
Exec sp_configure 'external scripts enabled', 1
Reconfigure with override
Statement and then i made sure the configuration setting was set to 1 which it is, and restarted the services inbetween checking and afterwards, but no luck.
I've also made sure i'm not side loading any other R open platform ide's or other versions of SQL Server versions except 2016 developer.
Run:
Exec sp_configure 'external scripts enabled', 1;
reconfigure;
Then restart the service from services.msc or restart your system.
Just restart the SQL Server from 'Services' or restart from Sql Server Management Studio
You have to run RECONFIGURE; after executing sp_configure 'external scripts enabled', 1; query before restarting the server.
I've tried using SSMS but when I click Attach I get error File Not Found. This is AdventureWorks2012_Data.mdf. There is no LDF file. I tried exec'ing this as well:
EXEC sp_attach_single_file_db #dbname='AdventureWorks2012',
#physname = N'R:\SqlServer\AdventureWorks2012_Data.mdf'
GO
but I get the same error:
failed with the operating system error 2 (The system cannot find the file specified.).
TRY the below snippet and you will be through without a .ldf file.
create database AdventureWorks2012_Data
on
(FILENAME='D:\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG
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 ?
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