SQL Server, Tabular Model - sql-server

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

Related

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

creating public database link

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'.

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...

Error in SQL Server updating Image datatype from a linked server

This is a table in a Microft Dynamics 2009 database. Our Test database is missing a bunch of Image data, so I would like to update the table in test with the data in production. I'm using this SQL for this update. When I execute this, I get this error:
Msg 8180, Level 16, State 1, Line 1
Statement(s) could not be prepared.
Msg 306, Level 16, State 2, Line 1
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Query:
UPDATE INVENTTABLE
SET
Z_IMAGE = i2.Z_IMAGE,
Z_IMAGEMIMETYPE = i2.Z_IMAGEMIMETYPE
FROM INVENTTABLE i1
JOIN [PRODSQLSERVER].[DAX2009DB].[dbo].INVENTTABLE i2
ON i1.RECID = i2.RECID
WHERE i2.Z_IMAGE IS NOT NULL
I can't see a place where I'm attempting to compare or sort the Image data.
Try changing UPDATE INVENTTABLE to UPDATE i1.

sql azure beginner- getting error for an simple insert statement

I am trying to insert a row of data into a table in SQL Azure --
This is the insert statement--
INSERT INTO cloud_storage_credentials (cloud_provider,api_key, api_secret)
VALUES("Rackspace", "<random_value>", "<random_value>");
However I am getting the following error--
Msg 207, Level 16, State 1, Line 2
Invalid column name 'Rackspace'.
Msg 207, Level 16, State 1, Line 2
Invalid column name '<random_value>'.
Msg 207, Level 16, State 1, Line 2
Invalid column name '<random_value>'.
What am I doing wrong here? I followed an SQL Server tutorial to write the above query...
change the " (double quotes) to ' (tick/single quote)
INSERT INTO cloud_storage_credentials (cloud_provider,api_key, api_secret)
VALUES('Rackspace', '<random_value>', '<random_value>');
Change your "s with 's. As it is, it thinks that the values you are inserting are name of columns.

Resources