SQL Server ADF Copy Dynamic Datatype Change in Loop for multiple table

f2uvfpb9  于 2023-10-15  发布在  其他
关注(0)|答案(1)|浏览(98)

I have to load multiple master tables from SQL Server to Azure ADLS using ADF. While loading I have to change the datatype of all column which are timestamp to string in a for each loop. Can this is possible using ADF ?

I tried for each loop of ADF, in that I used Copy data and tried to change the mapping configuration to map the timestamp datatype to string but was unable to do so.

bz4sfanl

bz4sfanl1#

AFAIK, if your schema is same for all the master tables then it will automatically Change the data type to string if you specified it in mapping.

If you are creating file dynamically it will automatically store the data as string when it is (CSV or txt file)

IF schema is not same for all tables, then as @Nadeem said create SQL file with all your SQL statements including conversion/ casting of timestamp column and add it into ADLS.

Convert() function: To convert a datetime to a string, you use the function as follows:

SELECT id, event_name,CONVERT(varchar(50),event_datetime,126)  as event_datetime FROM sample_table2;

then lookup the file using lookup activity

Lookup Output:

and loop over it with each query to copy the table with conversion on timestamp column.

Copy activity source setting:

相关问题