File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 264264 SET @SkipTrace = 1 ;
265265 END ; /* We need this permission to execute trace stuff, apparently*/
266266
267- IF NOT EXISTS
268- (
269- SELECT
270- 1 / 0
271- FROM fn_my_permissions(N ' xp_regread' , N ' OBJECT' ) AS fmp
272- WHERE fmp .permission_name = N ' EXECUTE'
273- )
274- BEGIN
275- SET @SkipXPRegRead = 1 ;
276- END ; /* Need execute on xp_regread*/
267+ IF ISNULL (@SkipXPRegRead, 0 ) != 1 /* If @SkipXPRegRead hasn't been set to 1 by the caller*/
268+ BEGIN TRY
269+ IF OBJECT_ID (N ' tempdb..#XpRegReadTest' ) IS NULL
270+ BEGIN
271+ CREATE TABLE #XpRegReadTest
272+ (
273+ [Value] varchar (20 )
274+ ,[Data] int
275+ );
276+ END ;
277+
278+ INSERT INTO #XpRegReadTest
279+ (
280+ [Value]
281+ ,[Data]
282+ )
283+ EXEC xp_regread @rootkey = N ' HKEY_LOCAL_MACHINE' ,
284+ @key = N ' ' ,
285+ @value_name = N ' ' ;
286+
287+ SET @SkipXPRegRead = 0 ; /* We can execute xp_regread*/
288+
289+ IF OBJECT_ID (N ' tempdb..#XpRegReadTest' ) IS NOT NULL
290+ BEGIN
291+ DROP TABLE #XpRegReadTest;
292+ END ;
293+ END TRY
294+ BEGIN CATCH
295+ SET @SkipXPRegRead = 1 ; /* We have don't have execute rights or xp_regread throws an error so skip it*/
296+ END CATCH ; /* Need execute on xp_regread*/
277297
278298 IF NOT EXISTS
279299 (
You can’t perform that action at this time.
0 commit comments