Creating SQL Server database in (or attaching from) Google Drive - sql-server

I tried to create a new SQL Server database in my Google Driver folder but I cannot even navigate to my GD and when I paste in the path I keep getting acces denied even when SSMS is running as Admin.
Also tried creating the DB in usual SQL Server Data folder, moving to my Gooogle Drive and attaching from there by pasting in the path because I cannot navigate to GD when trying to attache an existing DB but again I get access denied error...
Anyway, did anyone manage to create in or attach from Google Driver folders an SQL Server database or has any idea how to achieve this?

SSMS may be running as an admin, but the service account that SQL Server is using is the one that needs access to the folder. Can you verify that is the case

Related

Azure DevOps Pipeline Azure SQL Deploy won't work with SQL script (Failed to login)

I've been trying to deploy a database via a pipeline from Azure DevOps to an Azure resource group.
I have an ARM template for my database server in my Repo along with my DACPAC file.
In my release pipeline I first deploy the database server with an admin user defined in the ARM template to my resource group.
Then I use the "Azure SQL DacpacTask" to deploy the database schema. Here I give the admin credentials and it works flawlessly.
The issue is that the customer doesn't want it deployed as a DACPAC but rather an SQL script. They've given me a "CREATE TO..."-script from their database, created inside MS SQL Studio, which is also in my Repo.
The "Azure SQL DacpacTask" inside my release pipeline has an option for using an SQL file instead of DACPAC, but it doesn't work for me.
But no matter how I do it, my pipeline fails when running the "Azure SQL DacpacTask" and all I get, even in debug-mode is "Login failed for user '***'".
I can connect to the SQL Server through MSSQL Studio on my local machine using the admin credentials defined in my ARM template.
I've tried by adding the agent's IP before running the SQL script, but with no success.
Can anyone point me in the right direction or maybe tell me what I'm doing wrong? Why is it that it keeps failing to log in?
They want it deployed with little to no human interaction. Is it doable only through the ADO pipeline?
EDIT
Additional info:
I have tried with hardcoded password and user with no luck.
If I manually create a database and then try to deploy one via script and pipeline, it fails because a database already exists, and not because of a failed login.
I've setup Audit in Azure which generates 2 files with little to no info. I'm not sure what I'm looking at.

Restore .bak on Azure SQL database through SSMS: Failed to connect to Server ***. Login Failed for user ***

I am trying to restored a .bak file on an Azure SQL server through SSMS.
The reason why I am doing this is that my company unfortunately blocked any action on the Azure portal itself and therefore I have to find another way around.
I am able to connect successfully to the DB on Azure with my admin account through SSMS.
I first successfully restored the .bak on my local database. And then I am trying:
Again, I am able to connect through the same SSMS to the SQL db.
Moreover, when starting this procedure I get asked to connect first to the DB, which works successfully! What I mean is:
It doesn't give me any error, which is weird because if I try to connect with a wrong password it tells me right away that is wrong. So it kind of accepts it. It's only after when I really start the deployment that it gives me the problem:
Just for now, Azure SQL database doesn't support restore from .bak file.
You work flow should be right, restore the .bak file(database) into a local SQL Server firstly, then deploy the restored database to Azure with "Deploy database to Microsoft Azure SQL database".
Make sure you are using the server admin account of the Azure SQL database. Per my experience, the error is usually caused by the permission limits.
If all of these(SSMS) don't work, please thy other ways. Please try Data Migration Assistant(DMA) migrate the database. If DMA still give the same error, we can ensure that it's not caused by the tools, you need another higher Azure SQL database account permission.
HTH.
Working solution was to use the export data task:
For some reason this worked and the publish to ASQL task from SSMS didn't. I understand this is very based on the restrictions imposed by my company but at least this solution worked.
NOTE: as both Source and Destination use SQL Server Native Client .
Moreover when setting the Destination the refresh of the list of databases might not work (depending on your permissions on Server level) but if you type directly the name of the database it will work. Talking about this:

SSIS cannot access folder which everyone has access to

So we have a network address lets call it the Z drive that everyone has access to.
By everyone I mean the entire organization. For completeness, I actually went ahead and gave access to the actual SQL Server Agent.
The package runs fine on dev, but always fails with
The directory "Z:\SSIS_Test" does not exist
At first, I thought it was an issue of access. But how can't the SQL Server Agent access an everyone drive?
Also, I went in and run the package on the server myself as the caller and it still failed with same error. What gives? Am I not getting something?
Possible solutions
(1) Granting service accounts
Try giving read/write permissions to the SQL Database Engine Service account NT SERVICE\MSSQL$<Instance Name> and NT SERVICE\SQLSERVERAGENT (Where <Instance Name> should be replaced by the installed instance name):
Configure File System Permissions for Database Engine Access
I was facing the same issue, it looks like the "everyone" permission does not take into consideration service accounts (I am not sure). The issue was solved after granting the database engine and SQL agent service accounts. Also feel free to read more about SQL Server service account in the following documentation:
Configure Windows Service Accounts and Permissions
(2) Mapping drive within SQL Server
You can refer to the following article for more information:
Make Network Path Visible For SQL Server Backup and Restore in SSMS
Or you can try to use the full UNC path instead of the mapped drive.
If these solutions didn't worked, there are many other suggestions listed in the following answer, you can check it for more information:
SSIS File System Task Error while copying files between servers

vs 2017 entity core 2 not using the right data directory

experiencing an odd issue I've yet to see on any of my other machines. This is a fresh laptop, so I have installed VS 2017, SQL Server 2017 express, then created a quick sample project using one of the stock .net core projects (with authentication stored "in-app"). This, of course, creates some basic entity migrations and DB context.
When I run I'm getting access denied errors. So, of course, I checked SQL service default user which is an admin. I then run basic migration commands and receive this
So, of course, my next step was to double check the default data locations of SQL since it appears to be trying to store it in C:\Users root?! I have never had to bother touching this during install, but worth a look. And of course, they are as I expected in their default locations of C:\Program Files\ etc
Rapidly running out of things to try at this point - and considering this is a fresh windows 10 install, with bare-bones vs 2017 and SQL express 2017 it feels a lot like a bug here. Everything is a default if you were to File -> New Project -> .NET Core Web Application with INdividual accounts.
Anyone have any thoughts or things worth trying? Why is it trying to store my DB in C:\Users? Connection string -
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-WebApplication3-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true"
Thanks!
-Marc
You are not using SQL Server Express.
The local string says (localdb), which is the SQL Server engine running in user space. This is a big difference. Usually SQL Server or SQL Server express runs as service. (localdb) is not an alias for localhost (loopback address). It's a special name for a minified version of SQL Server which runs in user space.
When SQL Server runs as a service, it needs to have read/write permissions to the folder it writes. This is usually NOT THE CASE when the file is located within the User folder.
LocalDB on the other side, is always started when you start debugging your application and runs with the permissions of the user. So if your file was created by an admin user or outside of a directory you have write permissions.
Also, when you mount a database to SQL Server (Express), then the file is protected from write access to other applications, so LocalDB can't open it neither.
LocalDB is made for development to offer most of the SQL Server features but without all the hard setup and permanently running service in the background.
Essentially you have two options:
Use the SQL Server connection string as #TanvirArjel suggested
Detach the database from SQL Server express, copy it to your user folder (C:\Users\<myusername>\) and then correct the path to it
Then it should just work.
Notice that LocalDB is not meant to run in production, so you will likely experience issues when trying to run it in IIS (IIS Express and Console applications and WPF work fine).
Reasons for LocalDb not working with IIS is because ASP.NET (Core) applications within IIS run with a special user, but LocalDbs are always created in the users profile folder. Now, the accounts used by IIS don't have a profile and can't create the database and can't access any database outside (since localDbs are stored in user folder only the user who created it has access to it).
Here some source on it and the reasons behind it.
Using LocalDb with IIS
Write the connection string as follows.Hope it will work...
"DefaultConnection": "Server=YourPcName\\SQLExpressInstanceName;Database=aspnet-WebApplication3-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true"

How can I Upload my ASP.NET website(with database)?

this is my first project ^_^
and I have no previous experience.
I did create the database in my project from within the MVC.
Add New Item > SQL Server Database
then I use ADO.NET Entity DataModel
and I don't need to open my connection each time I deal with the database.. it's only the connection string in the Web.config..
my question is :
how can I upload my database?
is there any resource for such beginner as me :$ ?
I did Google it but I found it very hard for me to know if this is what I want or not, that's why I came here :$
It really depends on what type of access you have to your server.
If you have remote desktop access then run remote desktop (mstsc in run) and connect to your server.
This article shows how to install your web application in IIS on server.
This blog post from Scott Guthrie shows you how to deploy your sql database to your server.
In case you only have access to your server via a control panel (plesk) you should still be able to do the same via a different interface. (you need to go through the instructions given for the specific control panel you are using).
Hope this helps.
For ASP.Net website, just upload all files using FTP, in wwwroot folder of your hosting.
For SQL Server database there are following option.
Attach your MDF file on hosting database server (if you have remote desktop).
Generate a script of whole database with full data, schema, and indexes etc. and run the script in query editor of your hosting panel.
First of all create a database from your hosting panel and a user for your database then Use SQL Serer 2008 (R2 most preferable) and connect with your hosting SQL Server using hosting server name in Server name, your db user id in User Name, and same for password. And then connect, you will find a long list of databases including your own database. Now right click on your database and import data from your local database server to remote database server.

Resources