How to Restore SQL Backup within Visual Studio - sql

Got an SQL Backup file of database that generated via Visual Studio's>Server Explorer>"Publish to Provider"
but cannot restore that SQL Backup in Visual Studio's Query Window raises error:
Window title:"Query Definitions Differ"
Error Text:"DROP TABLE SQL construct or statement is not supported"
so
how can I execute an SQL Database Backup File ?(generated using VS>"Publish to Provider")
thanks.

Related

Visual Studio 2019 database project incorrectly reporting DATA_COMPRESSION option not supported in Azure SQL

Using a create table syntax as follows within a Visual Studio 2019 SQL Server Database Project:
CREATE TABLE [MyTable]
(
-- ...
) WITH (DATA_COMPRESSION = PAGE)
I receive the following build error:
SQL70015: Keyword or statement option 'DATA_COMPRESSION' is not supported for the targeted platform.
However, the DATA_COMPRESSION option is supported by Azure SQL Database as indicated by the documentation ("Compression is available in Azure SQL Database") and by the fact that I can manually execute this statement against an Azure SQL Database successfully.
I have configured the target platform to be "Microsoft Azure SQL Database" in the 'Project Settings' tab of the database project's properties page.
The false positive is preventing me from building (and thus deploying) the database project.
I had the same problem, the solution was:
1ª - {your project} >> properties >> change the "target plataform" to some thing else, save and build.
2ª - Change back to "Microsoft Azure SQL Database", save and build.
These steps will update the parameter of the project to newest version, in my case was:
From: Microsoft.Data.Tools.Schema.Sql.SqlAzureDatabaseSchemaProvider
To: Microsoft.Data.Tools.Schema.Sql.SqlAzureV12DatabaseSchemaProvider

SQL Azure Export Data-Tier Application & import into local SQL server

I have a SQL Azure database. I'm able to export the Database using Tasks > Export Data Tier Application. This is successful.
I then try to use Import Data Tier Application in my local SQL server and I get the following error:
Could not import package. Warning SQL0: A project which specifies
Microsoft Azure SQL Database v12 as the target platform may experience
compatibility issues with SQL Server 2008. Warning SQL72012: The
object [db_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 [db_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 102, Level 15, State 1, Line 1 Incorrect syntax near
'CREDENTIAL'. Error SQL72045: Script execution error. The executed
script: CREATE DATABASE SCOPED CREDENTIAL [databasenameAzureStorageCredential]
WITH IDENTITY = N'SHARED ACCESS SIGNATURE';
I have SQL Server Management Studio 14.0.17289.0 and everything is up to date.
I have read different posts on Stack overflow and done some googling but unsure the best way to move forward. How can I solve this?
It seems like there is a compatibility mode differences in your local SQL server DB and Azure SQL server DB. Check your compatibility level and if it is mismatched here is the resource to solve that. The error was because you use SSMS version 'X' to generate the bacpac against Azure SQL version 'Y'. Try to generate the same bacpac using SSMS version 'Y' and it works for me.
Please download the latest version of SQL Server Management Studio from here to have the best user experience with Azure SQL Database. SSMS v14 is too old. The current version of SSMS is v17.9.
Remove (drop) the database scoped credential named "databasenameAzureStorageCredential" before exporting the database. The following query should give you a list of credentials created.
SELECT * FROM sys.database_scoped_credentials
In general, you need to remove references to external sources before exporting your database.

execute a procedure one server A that pulls from server B

In SSIS (SQL Server 2008 R2), I'm using an OLE DB Command to repeatedly execute a procedure. The procedure is located on server A and calls server B. How do I let the OLE DB Command know how to access server B? (I can't move the procedure to server B.)
Step-by-step:
In the "Advanced Editor for OLE DB Command"->"Connection Managers" tab, I select server A.
In the "Advanced Editor for OLE DB Command"->"Component Properties" tab, I type "Exec myProc ?"
The "Column Mappings" gives an error: "Syntax error, permission violation, or other nonspecific error".
Thank you for the responses!
I was looking for a "Linked Server". It took me awhile to find it because in SQL Server Management Studio it's not under the database, but under the server itself in the "Server Objects" folder.
Once I made this in Management Studio the SSIS package could call the procedure without an issue.

MDX Step By Step Book

Am trying to learn MDX using book called "Microsoft SQL Server 2008 MDX Step by step", and i downloaded the samples databases for the book , but when trying to attach the database it gives me an error "Access denied" , I'm trying to attach the database to SQL Server 2008 R2,
will it make a difference to attach it to R2 as the book tutorial and samples is for 2008 only ??,
Note that i searched for the error and it said that i had to delete also the log file that is downloaded with the samples database, i did that also but nothing worked
Please help
I had the same error several times. It has nothing to do with your version, i have done it on both SQL Server 2008 and SQL Server 2012. It´s because of some denied access to the folders where you downloaded and installed the MDX-stuff. One way to solve it is to copy the "MdxStepByStep.mdf" & "MdxStepBySteplog" files to your data-folder where the other databases lies. My path is for example:
"C:\Program Files\Microsoft SQL Server\MSSQL11\MSSQL\DATA".
Then you just change the script´s path to:
exec master..sp_attach_db
'MdxStepByStep',
'C:\Program Files\Microsoft SQL Server\MSSQL11\MSSQL\DATA\MdxStepByStep.mdf'
Do not copy the "MdxStepByStep_log" because then you will get an error that the file already exists.
It should work, also there should not be any problem with the analysis cube if i remember correctly, tell me if there is and i will look into it.

How can I generate the SQL CREATE TABLE statement for an MDF table?

I have an .mdf file with Visual Studio 2008 with one table in it that has numerous columns of various types.
How can I generate the SQL statement that produces this table so that I can alter it and create another similar table? Is there a way to do this without SQL Server?
And MDF is a whole SQL Server database - not just a single table.
In SQL Server Management Studio, you can open the "Object Explorer" (View -> Object Explorer or press F7) and then select your database, right-click on it, pick "Tasks..." and then "Generate Scripts ....".
This will launch a wizard which allows you to script out all tables, views, stored procs and any object db objects you might have in your database.
If you're interested in just a single table, drill down into your database and then into tables and find your table in the Object Explorer, and then right click on the table. Pick "Script table as...." and then "Create To....." and you can have a CREATE TABLE script for just that single table in a file, a new query window in SSMS, or on the clipboard for your convenience.
As far as I know, you cannot do this inside Visual Studio, however - you will need to use SQL Server Management Studio (or the Express version of it for SQL Server Express databases).
Marc