0

On this page: AWS SQL Server RDS to S3

They say that they provide a stored procedure which uploads a CSV file from the RDS SQL Server file system, out to S3.

The following example uploads the file named data.csv from the specified location in D:\S3\seed_data\ to a file new_data.csv in the S3 bucket specified by the ARN.

exec msdb.dbo.rds_upload_to_s3 
    @rds_file_path='D:\S3\seed_data\data.csv',
    @s3_arn_of_file='arn:aws:s3:::bucket_name/new_data.csv',
    @overwrite_file=1;

But nowhere can I find a way to export that file from a database on that server. RDS SQL doesn't come with SQLCMD and looks like BCP isn't available either.

So, if they are saying that you can upload a CSV, then why is there no capability to create that CSV?

Anyone else notice this?

Thanks!

Dale K
  • 25,246
  • 15
  • 42
  • 71
A.G.
  • 2,089
  • 3
  • 30
  • 52

3 Answers3

0

You can use BULK INSERT commands as an alternative to bcp, through a SQL connection on port 1433.

wrschneider
  • 17,913
  • 16
  • 96
  • 176
0

You can use BULK INSERT T-SQL statement to import from file into your database.

BULK INSERT MyTable
FROM 'D:\S3\seed_data\data.csv'
WITH
( CODEPAGE = '65001'
   , DATAFILETYPE = 'char'
   , FIELDTERMINATOR = ','
);

Reference: https://learn.microsoft.com/pt-br/sql/t-sql/statements/bulk-insert-transact-sql?view=sql-server-ver15


Update

If you want to write a CSV file from SQL Server, maybe you can try the approach below. I am not sure if it is supported by RDS.

INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=D:\;HDR=YES;FMT=Delimited','SELECT * FROM [FileName.csv]')
SELECT Field1, Field2, Field3 FROM DatabaseName

You can read more about this suggestion on link below:
Export query result to .csv file in SQL Server 2008

Azize
  • 4,006
  • 2
  • 22
  • 38
  • Thanks, but what I'm asking is how to get the data onto the csv file in the first place. I have found the answer and it's with SSIS. However this requires AD integration. – A.G. Jun 02 '21 at 12:58
0

The answer is that that to get the data to a CSV file on the RDS instance you must use SSIS. However this requires AD integration.

A.G.
  • 2,089
  • 3
  • 30
  • 52