Best way to create an SQL Server DB in AWS using Terraform? - sql-server-2005

To Devs, I am trying using the following:
enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports
create_cloudwatch_log_group = var.create_cloudwatch_log_group
cloudwatch_log_group_retention_in_days = var.cloudwatch_log_group_retentions
cloudwatch_log_group_kms_key_id = var.cloudwatch_log_group_kms_key
to create a SQL server DB on AWS using Terraform but am not able to create it with logging and encryption capability. But it does not work. Any ideas this? Thanks,

Related

SQL Server creating external data source

I'm trying to create external data source in SQL Server 2019. From one SQL Server instance to another.
I have done everything like in documentation (https://learn.microsoft.com/en-us/sql/relational-databases/polybase/polybase-configure-sql-server?view=sql-server-ver15).
To create external data source i use following command:
CREATE EXTERNAL DATA SOURCE SQLServerInstance
WITH ( LOCATION = 'sqlserver://SQL2:port',
PUSHDOWN = ON,
CREDENTIAL = MyCredentials);
But i keep getting following error:
Msg 46721, Level 20, State 1, Line 1
Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication.
What can I do to fix this?
Are you running the DDL from a local Windows account (i.e., non-domain joined machine)? There is a regression in SQL Server 2019 where you will get this error when trying to use PolyBase. We are in the process of fixing the issue in an upcoming CU.

How to set up SSIS to extract data from Postgres Database

I have a database PostGres database in the AWS Cloud. I would like to use SSIS to extract tables and move them over to a local SQL Server.
Has anyone attempted to do this? Is it possible?
Ultimately I would like to move over tables from the PostGres to a SQL server, without having to purchase a tool.
As per the documentation, you would need to follow these steps to connect SSIS to a Postgres database:
get the PostgreSQL ODBC driver, either with Stack Builder or using ODBC
connect to PostgreSQL with the PostgreSQL ODBC driver (psqlODBC), using the proper connection string, typically Driver={PostgreSQL ODBC Driver(UNICODE)};Server=<server>;Port=<port>;Database=<database>;UID=<user id>;PWD=<password>
You can use the Postgres OLE DB Provider to connect to Postgres using OLE DB Source. The following link contains a step by step guide to import data from Postgres into SQL Server:
Export data from Postgres to SQL Server using SSIS

How to perform cross-server queries from Azure Cloud Database to On Premise Server Database

Goal
To create a query from an Azure server SQL Database to an on premise server server database.
This query used to be made using linked server objects from two on premise servers with their respective databases.
I have already successfully done cross database queries between two databases on the Azure cloud server. However, I have not been able to replicate the similar aspect that a linked server object can provide between an Azure server and an on premise server.
Current Scenario
On serverA I have created a linked server object to serverB. My two on premise servers communicate as such below:
--serverA = on premise server
--serverB = on premise server
Using mycn As New SqlConnection("Data Source=serverA;Initial Catalog=DatabaseA;User Id=username;Password=pwd")
Dim query As String = "SELECT * FROM [DatabaseA].dbo.tableA " &
"INNER JOIN [serverB].[DatabaseB].dbo.tableB ON tableA_ID = tableB_ID"
End Using
External Data Source
In order to communicate with my on premise server to my Azure SQL server I must create an external data source... I believe my problem relies in my external data source.
-- ===========================================================
-- Create external data source template for Azure SQL Database
-- ===========================================================
IF EXISTS (
SELECT *
FROM sys.external_data_sources
WHERE name = N'serverB_DataSource'
)
DROP EXTERNAL DATA SOURCE serverB_DataSource
GO
CREATE EXTERNAL DATA SOURCE serverB_DataSource WITH
(
TYPE = RDBMS,
LOCATION = N'serverB',
DATABASE_NAME = N'databaseB',
CREDENTIAL = myCreds
)
GO
Since I am trying to access my on premise server called serverB from the Azure server, do I need to specify it's actual IP? Not sure what I'm missing here...
Since I am trying to access my on premise server called serverB from the Azure server
you can't do this.. but you can do other way around
Lets say your azure server name is AZ and onpremises server name is B... you can create a linked server for AZ in B and query AZ from B

Connect SQL Server to SAP Backend (also a SQL Server)

I am trying to connect my SQL Server directly to the SAP backend database so that I don't have to extract the data everyday (for fresh data) using SSIS packages.
Instead I want to create views that will access this data directly (direct querying) and get refreshed periodically.
Can someone give me a link or show/tell me the steps on how to do this?
If you know the hostname of the backend server, you can do something like this:
SELECT TOP 1 * FROM hostname.databasename.dbo.tablename
If you want to access your data from external SQL server directly in SAP you can define connection to external database in transaction DBCO:
Then in your ABAP code you can write SQL statements using OPEN SQL:
EXEC SQL.
CONNECT TO my_new_connection.
ENDEXEC.
...
EXEC SQL.
SELECT * INTO TABLE :lt_internal_table FROM dbtable.
ENDEXEC.
...
EXEC SQL.
DISCONNECT my_new_connection.
ENDEXEC.
or using Classes CL_SQL_CONNECTION, CL_SQL_STATEMENT. An Example program ADBC_DEMO show how to use it.

Creating index in SQL Server with ONLINE = ON if supported

I'm creating an index in a SQL Server table with ONLINE = ON option:
CREATE INDEX IX_Name ON Users (Name) WITH ONLINE = ON
If this script is run on non-Enterprise SQL Server edition I get this error:
Online index operations can only be performed in Enterprise edition of SQL Server.
How to write a SQL script to use ONLINE = ON option on Enterprise editions and not to use it for non-supported editions?
Something like this should help
IF SERVERPROPERTY ('edition') like '%Enterprise%Edition%'
BEGIN
CREATE INDEX IX_Name ON Users (Name) WITH ONLINE = ON
END
Also I think the login you are using should have permission to View Server State