S
Scott M.
How do you consume the result of a SQLCLR stored procedure when it returns a
SQLDataRow?
Thanks.
SQLDataRow?
Thanks.
Charles Wang said:Hi Scott,
What is your meaning of SQLDataRow here? There is a recordset type named
SQLDataRecord in SQL CLR data types. Did you refer to it?
It is easy to create/deploy a CLR stored procedure within Visual Studio
2005. After that, you can invoke it just as the SPs created in SQL Server
Management Studio (SSMS).
For example, I created a SQL CLR project with C#. The following code is
the
CLR SP I created:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void USPTest()
{
// Create a record object that represents an individual row,
including it's metadata.
SqlDataRecord record = new SqlDataRecord(new SqlMetaData[] { new
SqlMetaData("stringcol1", SqlDbType.NVarChar, 128), new
SqlMetaData("stringcol2",SqlDbType.NVarChar,50) });
// Populate the record.
record.SetSqlString(0, "Hello World!");
record.SetSqlString(1, "Test");
// Send the record to the client.
SqlContext.Pipe.Send(record);
}
};
Then I built the project, right clicked the project and clicked Deploy,
and
then I could directly run the SP in SSMS:
USE <database name>
Go
EXEC USPTest
The result is as follows:
stringcol1 stringcol2
Hello World! Test
In addition to directly deploying the CLR procedure in VS2005, if you
like,
you can manually deploy your CLR procedure via CREATE ASSEMBLY and CREATE
PROCEDURE. The following article talks very detailed of creating a CLR
procedure and manually deploying a CLR procedure:
CLR Stored Procedures
http://msdn2.microsoft.com/en-us/library/ms131094.aspx
Hope this helps. If you have any other questions or concerns, please feel
free to let me know. Have a nice day!
Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
======================================================