SQL Server Management Studio connects, but can't perform a select against Azure database? - sql

I've successfully connected to an Azure hosted SQL database in SQL Server Management Studio, but I can't perform any queries that I can perform in web matrix.
The following query works just fine in web matrix:
SELECT *
FROM [junglegymSQL].dbo.Action AS a
But when I try to execute it in SQL Management Studio I receive the following error:
Msg 40515, Level 15, State 1, Line 16
Reference to database and/or server name in 'junglegymSQL.dbo.Action' is not supported in this
version of SQL Server.

Remove the [junglegymSQL] from your SQL.

Related

Apply SQL Server schema after 'schema compare' show error

Versions in use:
SQL Server 2016
Azure Data Studio 1.36.2
SQL Server Schema Compare 1.13.1
Problem: there is something wrong with my Azure Data Studio apply schema to SQL Server 2016.
It say I'm not the login manager but there is no login manager role in SQL Server.
And it has worked before updating Azure Data Studio to v1.36.X
https://imgur.com/a/JFWFOtn
Finally, I found the problem
Misused sqllinlinetablevaluedfunction and sqlmultistatementtablevaluedfunction
In my project There are many function use sqllinlinetablevaluedfunction instead of sqlmultistatementtablevaluedfunction but It's should be used sqlmultistatementtablevaluedfunction
so I change to Correct Type then It's worked. The error never show

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 remote SQL script with linked server

I've got 2 servers in a workgroup called "workgroup".
Server A is W2012R2 with SQL Server 2012.
Server B is W2012R2 with other application. SQLCMD Utility has been installed on server B.
I'm using local account, SQL service is start by local account. I can connect to the SQL server from B to A. I can launch query without difficulty. When I launch my SQL script, I get the following error:
E:\Batch\Script>sqlcmd -S YMSQL01 -i test.sql
Changed database context to 'PROD'.
Msg 7399, Level 16, State 1,
Server YMSQL01, Procedure V_C_Prod, Line 3 The OLE DB provider
"Microsoft.ACE.OLEDB.12.0" for linked server "C_PROD" reported an
error. The provider did not give any information about the error.
Msg 7303, Level 16, State 1, Server YMSQL01, Procedure V_C_Prod, Line 3
Cannot initialize the data source object of OLE DB provider
"Microsoft.ACE.OLEDB .12.0" for linked server "C_PROD".
As you can see, it seems that I cannot query on a view. This view is from a linked server which is connected to an Excel file (located on server B). I have installed the same ODBC driver on server B but I get the same error.
My SQL script:
Use PROD
Go
Merge dbo.conc AS t
using V_C_Prod as s
ON (t.CodeComptable=s.[Code Comptable])
WHEN MATCHED THEN UPDATE SET
t.[Marque]=s.[Marque]
,t.[CodeHolding] = s.[Code HOLDING]
,t.[Email1]=s.[Email Principal]
,t.[CP]=s.[CP]
,t.[Ville]=s.[Ville]
WHEN NOT MATCHED
THEN INSERT VALUES (
s.[Marque]
,s.[Code HOLDING]
,s.[Code Comptable]
,s.[Email Principal]
,s.[CP]
,s.[Ville];
Go
How can I solve this issue?

Excel Linked Server in SQL Server 2008 R2 OLEDB error

I have set up a linked server from SQL Server 2008 R2 to an Excel spreadsheet, from which I read the contents in to a table, for comparison during an import.
The spreadsheet is held on a network share from an application server.
Basically, this works perfectly on the SQL Server when I run:
SELECT * FROM SpreadsheetLink...[CONTENTS$]
However, as I now need to schedule this, I need to create an SSIS package on the application server, which runs the same query.
So now, whenever I try to do this though (either by writing the script in to SSIS or by logging in to SQL Server Mgmt Studio on the App server and then opening an SQL connection to the SQL Server and querying directly) I get an error:
Msg 7399, Level 16, State 1, Line 1
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "SpreadsheetLink" reported an error. The provider did not give any information about the error.
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "SpreadsheetLink"
I first wondered whether I had forgotten to install OLEDB12.0 on the application server, but it is there.
I next wondered whether it was a permissions issue, so I added the EVERYONE group, with "Full Control" to the folder containing the spreadsheet and also ensured that the account that I am both logged in with and running the query as is an administrator on both the SQL server and the Application Server.
I also checked that the account was a member of the Distributed COM user group on both servers (it was).
Additional info:
I have tried several things, but it still fails.
I added the following
sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
I then re-tested, but got the same results (success from the local SQL server, failure from the other server).
Next, I tried creating a different query, referring to the spreadsheet directly by path, rather than by Link-name, but that resulted in exactly the same outcome:
SELECT * INTO TargetTableName FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0;Database=\\SERVER_NAME\PATH\fileName.xls;HDR=YES',
'SELECT * FROM [sheetName$]')
I also applied all of the suggestions in the following page:
http://visakhm.blogspot.co.uk/2013/12/how-to-solve-microsoftaceoledb120-error.html. But still no joy.

Intellisense not working in SQL Server Management studio. what could be reason?

I have been working on SSMS 2008 for last 1 month, I have enabled intellisense
Not sure why but it just does not work. what could be reason?
We had the same problem with Intellisense not working, in both SSMS version 17.9 and 18.0 and 18.1, when using Azure SQL DB, on accounts that were not dbmanager.
The suggestion from #sundar helps, even if it reports an error
Msg 40508, Level 16, State 1, Line 1
USE statement is not supported to switch between databases. Use a new connection to connect to a different database.