January 19, 2015 at 9:31 pm
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
January 20, 2015 at 3:36 am
@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
January 20, 2015 at 7:21 am
"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