dotnet / dotnet/EntityFramework.Docs

SQL Raw Documentation Nice - needs more verbs on OUTPUT vs. INPUT parameters (Direction)

Open
#3,059 2 comments 0 reactions 0 assignees View on GitHub
area-query-raw
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

The documentation for SQL Raw querying (passthrough) in EF Core is nicely done, so good on that. I only need a few more examples for "deeper" stored procedures, which are far more likely "in the field". The following procedure call (argued), takes a tabbed text file, which is very useful in Azure, and implements an OLEDB "OPENROWSET" with a format file, to seed raw data into a table. Here, we pass arguments into an INPUT parameter, and receive OUTPUT data as to return code (standard practice), success output, and the path for an error file. Azure offers a URL to a BLOB, so if this procedure is to be implemented on Azure, I would need to test further on that platform. We need documentation that explains more complex scenarios like this, both on-Premises, and with the Azure offerings. Really, it is **_very_** common to SEED tables with raw, tabbed text files - a lot more common than anyone might assume. Anyway, Mr. Vickers and friends, we here at **_Monkey Brains Studio_** do very much appreciate the great documentation that you and the team have produced. Also, seeing Mr. Bill Gates on MSNBC today, who was discussing the Pandemic in a very honest and open way, inspired me go back to this computer and key this issue in to GitHub. Thanks to everyone there! So, without further ado and many debts due, here is the signature I offer for a more specific attempt to further document just how EF Core would handle such a scenario:

```
DECLARE @ReturnCode INTEGER,
@SchemaName NVARCHAR(20),
@TableName NVARCHAR(100),
@UNC_QualifiedErrorFilePath NVARCHAR(200),
@UNC_QualifiedSeedFilePath NVARCHAR(200),
@UNC_QualifiedFormatFilePath NVARCHAR(200),
@PrintOnly BIT,
@WithTruncate BIT,
@InsertErrorRowOnly BIT,
@Message_OUT NVARCHAR(MAX),
@ErrorMessage_OUT NVARCHAR(MAX),
@RowCount_OUT INTEGER;

EXECUTE [Meta].[Seeding]
@SchemaName = [Hub],
@TableName = [Intervals],
@CodePage = 1252,
@StartingRow = 1,
@UNC_QualifiedErrorFilePath = '\\WHITESAND\OutputFiles\Errors.txt',
@UNC_QualifiedSeedFilePath = '\\WHITESAND\InputFiles\Intervals.txt',
@UNC_QualifiedFormatFilePath = '\\WHITESAND\FormatFiles\Intervals.xml',
@PrintOnly = 0,
@WithTruncate = 1,
@InsertErrorRowOnly = 0,
@Message_OUT = @Message_OUT OUTPUT,
@ErrorMessage_OUT = @ErrorMessage_OUT OUTPUT,
@RowCount_OUT = @RowCount_OUT OUTPUT;
GO
```

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 7e1289d5-8364-18a4-3445-6bba05c6854b
* Version Independent ID: 2680e647-f64a-7991-f821-3b5e2a845960
* Content: [Raw SQL Queries - EF Core](https://docs.microsoft.com/en-us/ef/core/querying/raw-sql)
* Content Source: [entity-framework/core/querying/raw-sql.md](https://github.com/dotnet/EntityFramework.Docs/blob/master/entity-framework/core/querying/raw-sql.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @smitpatel
* Microsoft Alias: **avickers**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.