Archivio

Archivio per la categoria ‘Sql Server’

[SQL server] how to pass array to stored procedure

6 novembre 2009 zaragon Nessun commento

Through Google I found this useful function to pass array to stored procedure.

CREATE FUNCTION array2table (@list nvarchar(MAX))
   RETURNS @tbl TABLE (number int NOT NULL) AS
BEGIN
   DECLARE @pos        int,
          @nextpos    int,
           @valuelen   int
   SELECT @pos = 0, @nextpos = 1
   WHILE @nextpos > 0
   BEGIN
      SELECT @nextpos = charindex(',', @list, @pos + 1)
      SELECT @valuelen = CASE WHEN @nextpos > 0
                              THEN @nextpos
                              ELSE len(@list) + 1
                         END - @pos - 1
      INSERT @tbl (number)
         VALUES (convert(int, substring(@list, @pos + 1, @valuelen)))
      SELECT @pos = @nextpos
   END
  RETURN
END

CLR Stored Procedures in C#

1 agosto 2008 zaragon Nessun commento

Ieri ho scritto un promemoria per ricordami di come attivare CLR in SQL Server 2005, oggi vi posto il link di un iteressante articolo su come scrivere CLR Stored Procedures in C#.

Ecco un articolo veramente ben scritto che illustra i passi necessari per creare il project su Visual Studio corredato da codice di semplice comprensione:

Writing CLR Stored Procedures in C# – Introduction to C# (Part 1)

Writing CLR Stored Procedures in C# – Returning Data (Part 2)

Attivare CLR integration in SQL Server 2005

31 luglio 2008 zaragon Nessun commento

Promemoria:In fase di creazione di una CRL Stored Procedure, ricordarsi di attivare tale funzionalità  visto che di default è disabilitata.

Start –> SQL Server 2005 –> Configuration Tools –> Surface Area Configuration –> Surface Area Configuration for Features

selezionare CLR Integration, attivare e salvare.