Sanjeev S
Sanjeev S

Reputation: 624

How to bulk import as user defined formatted data and stores as a varbinary(max) in MSSQL

I wanted to select from couple of tables and need output as delimiter separated and stores this data into a table field which is declared as varbinary(max).

2018    | abc   | 2019-08-29
2018    | aab   | 2019-08-29
201907  | aab   | 2019-08-29

required output format

2018;abc;2019-08-29
2018;aab;2019-08-29
2019;aac;2019-08-29

Which I wanted to insert as a varbinary(max) field in to the database.How can I achieve it. Please suggest me a solution for this. Any tool which helps to bulk insert?

Upvotes: 0

Views: 41

Answers (2)

CompEng
CompEng

Reputation: 7416

try this:

SELECT LEFT(Column1, 4)+ ';'+ Column2+ ';'+Column3

Upvotes: 1

Arulkumar
Arulkumar

Reputation: 13247

Using CONCAT() you can achieve your expected format:

SELECT CONCAT(LEFT(ColumnName1, 4), ';', ColumnName2, ';', ColumnName3)

Upvotes: 1

Related Questions