I'm having an issue with inserting parameter through a SQLCommand in C#. When parameter legal_GUID was in the end of query it works well.
string[] param = getHTTPparams(connection);
SqlCommand command = new SqlCommand(@"SELECT AD.document_GUID ,AT.attachment_fileName ,do
FROM [legal].[mdm].[View_All_Documents] AD
LEFT JOIN [legal].[dbo].[AllAttachments] AT
ON AD.document_GUID = AT.document_GUID
WHERE AD.legal_GUID = '" + legal_GUID + "'", connection);
But when i am trying to make changes to query and current parameter legal_GUID moves to the middle of the query it doesn't work.
SqlCommand command = new SqlCommand(@"DECLARE @order_guid_tr uniqueidentifier
SELECT 1 @order_guid_tr = Order_guid
FROM [legal].[mdm].[View_All_Documents]
WHERE legal_GUID = '" + legal_GUID + "'
SELECT AD.document_GUID ,AT.attachment_fileName, document_type
FROM [legal].[mdm].[View_All_Documents] AD
LEFT JOIN [legal].[dbo].[AllAttachments] AT
ON AD.document_GUID = AT.document_GUID
WHERE AD.ORDER_GUID = @order_guid_tr", connection);
What changes do I need to make to the query syntax, what do I miss?
1inSELECT 1 @order_guid_tr = Order_guid...doesn't look right.