0
我有以下存儲過程在我的SQL Server 2008 R2數據庫如何運行SQL Server存儲過程查詢的CSV
ALTER PROCEDURE [dbo].[usp_send_email]
@pStatus Int Out,
@pEMailId Int Out,
@pSenderUserName varchar(MAX),
@pReceivers VarChar(50), **-- this column can have csv values**
@pSub NVarChar(100),
@pCon NVarchar(MAX),
@pHasAttachments Bit
AS
BEGIN
--SET NOCOUNT ON;
Insert Into MessagingMessage
(
CreatedBy,
[Subject],
Body,
HasAttachments
)
Values
(
@pSenderUserName,
@pSub,
@pCon,
@pHasAttachments
)
SET @pEMailId = SCOPE_IDENTITY()
Insert Into MessagingMessageReceipient
(
MessageId,
ReceipientId,
ReceipientType
)
Values
(
@pEMailId,
@pReceivers,
1
)
SET @pStatus = SCOPE_IDENTITY()
END
在上面的代碼中的每個值我想要運行的第一條語句只有一次但第二個插入語句循環中的每個逗號分隔username.CSV值作爲參數已經由C#代碼驗證,因此不需要驗證它。
感謝下面複製了很多,我將用它 – Abhi