admin on November 12th, 2007

SELECT
        ‘nameValue’ AS “@name”,
        CAST(’<!– your comment –>’ AS XML),
        ‘anotherValue’ AS “another”,
        (SELECT ‘i’ AS “@name”, ‘1′ AS “@value” FOR XML PATH(’item’), TYPE),
        (SELECT ‘j’ AS “@name”, ‘2′ AS “@value” FOR XML PATH(’item’), TYPE)
FOR XML PATH(’sample’), ROOT(’root’)

output

<root>
  <sample name=”nameValue”>
  [...]

Continue reading about SQL 2005 generates XML comment, array of elements

admin on May 3rd, 2007

In MS SQL, the current stored procedure name can be obtained from the follow SQL snippet. It is useful for logging purposes.

– omitted code for SP.
DECLARE @Name NVARCHAR(256)
SELECT @Name = OBJECT_NAME(@@PROCID)
SELECT @Name
– omitted code for SP.
 

The value would be null if the it is not executed in stored procedure context.

Continue reading about MSSQL Get Current Stored Procedure Name