> For the complete documentation index, see [llms.txt](https://docs.langstack.com/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.langstack.com/welcome/in-depth-learning/connectors/ms-sql-connector/using-ms-sql-connector-in-etl-pipeline/ms-sql-connector-as-a-source.md).

# MS-SQL connector as a source

The ETL pipeline, to transfer customer data from an MS-SQL table to a Langstack entity, is created as follows.

{% hint style="info" %}
To see step-by-step instructions of how to create an ETL pipeline, [click here](/welcome/get-started/learn-langstack/introduction-to-etl-pipeline.md).
{% endhint %}

* An ETL pipeline named “Tutorial\_MSSQL\_to\_entity” is created.&#x20;

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FBnCrhP3bZ1eDabXFfJ8o%2FTutMSSQL2Entity_Name.png?alt=media\&token=19d26714-72b7-44aa-83e8-8810b95ed1e6)

* To connect to the data source, the necessary information is added as follows:&#x20;
  1. The “Connector” tab is selected.&#x20;
  2. For this example, “Tutorial\_MSSQL” is selected from the drop-down menu.&#x20;
  3. To go to the settings, click the “Edit the settings” arrow.&#x20;

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FyJxxgGe6YGXI3pQDlfco%2FDataSource_TutMSSQL.png?alt=media\&token=7127623d-411c-43b4-bc04-1d61d76b382b)

* To connect to the data destination, the necessary information is added in the Data destination section:&#x20;
  1. The “Entity” tab is selected.&#x20;
  2. The “TEST\_MSSQL\_Entity” is selected from the drop-down menu.
  3. To view the entity records, click "Go to records."

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FpD3nrabFtDpNZHHJxVWa%2FDataDest_TestMSSQLEntity.png?alt=media\&token=25459946-7c31-4e6c-b105-243288eb77be)

* The default selection for ETL pipeline execution is “Immediate”.&#x20;

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FoPt5II2hBVZaMUekbKoI%2FImmediate.png?alt=media\&token=8983b1ed-81af-44f0-9fac-d35e991369c6)

* To align the source fields with destination fields, the settings for the reader and writer format are defined in the “Data Format” tab. \
  The “Reader” tab is selected by default.

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2Feo4NB2r9SClnKgFBUw75%2FDataFormat_Reader.png?alt=media\&token=1ed5df2a-d4d3-457e-af0a-80c69bc0badd)

* To update the settings for how the data should be read from the MS-SQL database:&#x20;
  1. The Reader stream is “Database Stream.”&#x20;
  2. To add the table name, click the “Edit the settings” arrow.

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FDjNYSmeluDFQvwPV89xr%2FDataFormat_Reader_DBStream.png?alt=media\&token=6a56b2ae-b4e1-49b4-bacc-017e91506695)

* To add the table name to read the records from

  1. The MS-SQL table name is added "TEST\_MSSQL" in the section “MS-SQL format details”.&#x20;
  2. Click on "Accept & Collapse" to save the information.

  ![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2Fd0yFnrYoe2s1s0sIjiqy%2FMSSQLFormatDetails.png?alt=media\&token=7cb723cb-0bf5-4a25-9c79-84376a78ef2c)
* In the Source fields section, all the four fields have been added as per the image below.

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FMhQQbpZF1sKl96FAwghi%2FMSSQLReader_Allsourcefields.png?alt=media\&token=e4d95604-4bde-4142-bf81-0871700c24ac)

* To define that the data is written to the destination as mentioned in reader source fields without transforming it, the “Writer Mode” is selected as “Append”.

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FB9fdAhglhDg0m4z7LDW2%2FWriterMode_Append.png?alt=media\&token=84fa88eb-51c0-4be6-9738-544eeb17e3d7)

* In the Field Mapping section, all the “Mapped Fields” are added and aligned.

![](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FqoCpUFLfrHzcwHyeYhre%2FMSSQLDataSource_AllMappedFields.png?alt=media\&token=415f53f5-c5ea-4da3-a355-8d816746f91f)

* When the ETL pipeline is executed (after Save and Publish), the records will be added to the destination entity. \
  The bit data type in MS-SQL is mapped to the boolean data type in Langstack in the case of the field “active\_status”. The 0 is converted to false and 1 is converted to true.

![“active\_status” field in source](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2F4hQeFSQOQLPM0W4gAtSL%2FMSSQLTable_activestatus.png?alt=media\&token=586bf843-6149-470b-b3a5-72a870d6685b)

![“active\_status” field in destination](https://2351945889-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVoxOh7gdjWdmqooFdYBY%2Fuploads%2FvauIdDCVI1GIHgTBzs52%2FMSSQL_activestatusinEntity.png?alt=media\&token=ad2fdbed-7798-417f-9fe4-82c22c015bb8)
