creating public database link - database

i'm trying to create a public database link to an sql server and am constantly getting syntax error.
This is the command
CREATE PUBLIC DATABASE LINK AMRCMSLINK CONNECT TO "dbacecg" IDENTIFIED BY "#dbac#ecg#" USING "CMSPRO";
am getting this error:
Msg 156, Level 15, State 1, Server RMR, Line 1
Incorrect syntax near the keyword 'PUBLIC'.

Related

Trace file name is invalid

I am trying to copy the trace file information to SQL table with fn_trace_gettable function, but while running this function I am getting 'Trace file name is invalid'. And I confirmed the path and file name are correct and the default trace is enabled. Following is my SQL code, what I am doing wrong?
USE TestDB
SELECT * INTO [dbo].[traceTable]
FROM ::fn_trace_gettable(N'‪D:\MAT25.trc', default)
Error Message:
Msg 19050, Level 16, State 6, Line 11
Trace file name '‪‪D:\MAT25.trc' is invalid.
The statement has been terminated.

Using SQL Server Polybase and CSV file as data source

Anybody that actually got this to work? To use a csv-file as a datasource with polybase? I've just get the error message below.
Msg 105082, Level 16, State 1, Line 12. See the rest in code block.
Got the latest updates both of SQL Server 2019 EE, OS and ODBC and Microsoft Access Text Driver. The user has the right credentials. Creating the external data source is no problem, it's when trying creating the external table the error occurs. Can anybody see the any obvious error
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'TOPSECRET_PSW';
GO
CREATE EXTERNAL DATA SOURCE TestCSV
WITH
(
LOCATION = 'odbc://localhost',
CONNECTION_OPTIONS = 'Driver=Microsoft Access Text Driver (*.txt, *.csv);Dbq=D:\APA\',
PUSHDOWN = OFF
);
CREATE EXTERNAL TABLE dbo.testCSV
(
Header1 nvarchar(128)
,Header2 nvarchar(128)
)
WITH
(
LOCATION='[testCSV.csv]',
DATA_SOURCE = TestCSV
)
Msg 105082, Level 16, State 1, Line 12
105082;Generic ODBC error: [Microsoft][ODBC Text Driver]General error Unable to open registry key Temporary (volatile) Ace DSN for process 0x1608 Thread 0x3450 DBC 0x8d76d578 Text'. Additional error <2>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 Additional error <3>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 Additional error <4>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 Additional error <5>: ErrorMsg: [Microsoft][ODBC Text Driver]Invalid connection string attribute SERVER, SqlState: 01S00, NativeError: 8 .
You need to apply latest SQL Server 2019 CU to get rid of that message. However, once that error disappears, I couldn't make it work on Docker, are you using a physical machine?

SQL Server, Tabular Model

CREATE SECURITY POLICY Security_Policy
ADD FILTER PREDICATE RLS.fn_CanSeeSalary(EmployeeName)
ON dbo.Salary
WITH (STATE = ON);
When I execute the query above I get the following error:
Msg 343, Level 15, State 1, Line 37
Unknown object type 'SECURITY' used in a CREATE, DROP, or ALTER statement.
Msg 102, Level 15, State 1, Line 38
Incorrect syntax near 'FILTER'.
CREATE SECURITY POLICY Security_Policy
ADD FILTER PREDICATE RLS.fn_CanSeeSalary([EmployeeName])
ON dbo.Trn_AccDet

How to fix could not use view or function because of binding errors

I have Table-valued function when trying to execute I am getting below error
Msg 208, Level 16, State 1, Procedure IPTRate, Line 19 Invalid object
name 'DBName.dbo.AccessTable'. Msg 4413, Level 16, State 1, Line 3
Could not use view or function 'dbo.ExchangeRate' because of binding
errors.
Actually the database name recently renamed from DBName to DBNameNew. Is the error because of database rename? how to fix this. please suggest.
Thanks.
Error message is clear..
Msg 208, Level 16, State 1, Procedure IPTRate, Line 19 Invalid object name 'DBName.dbo.AccessTable
you will need to rename all the views

How to set data and log file location for SQL Database?

I'm trying to create a database where the data and log files are saved to the E drive but not sure how to do so. I've tried:
CREATE DATABASE TachographDataContent_Archive
[ON E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data]
[LOG ON {D:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data}]
And I'm getting this error:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'IF'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'TachographDataContent_Archive'.
To create database using query, you need to mention .mdf and .ldf file. So try below script.
Like this
CREATE DATABASE [TachographDataContent_Archive]
ON PRIMARY (NAME = 'TachographDataContent', FILENAME = 'E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data\TachographDataContent.mdf')
LOG ON
(NAME = 'TachographDataContent_log', FILENAME = 'E:\MySqlDir\MSSQL.MSSQLSERVER\MSSQL\Data\TachographDataContent_log.ldf')
GO
good luck...

Resources