@HR

  • I'm trying to get up to speed on sp_OACreate and related OLE objects. I see the variable @HR used in many examples. What is the significance of that acronym? I haven't been able to figure it out. An example is copied below.

    DECLARE @object int;

    DECLARE @hr int;

    DECLARE @src varchar(255), @desc varchar(255);

    EXEC @hr = sp_OACreate 'SQLDMO.SQLServer', @object OUT;

    IF @hr <> 0

    BEGIN

    EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT

    raiserror('Error Creating COM Component 0x%x, %s, %s',16,1, @hr, @src, @desc)

    RETURN

    END;

    GO

    Thank you,

    Rob

  • @hr is just the name of the variable to store result of the sp_OACreate proc.

    As per BoL (http://msdn.microsoft.com/en-us/library/ms189763.aspx), this proc returns HRESULT, so @hr is just choosen as it kind of resamables this word.

    You can name it as you wish, as long as it of INT datatype.

    That what HRESULT means: http://msdn.microsoft.com/en-us/library/ms189556.aspx

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • "HResult..." Thanks for the heads up on that.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply