SQL Server 2000 : INSERT INTO . . EXEC problème
Bonjour,
J'ai récupéré sur le net une requête T-SQL qui permet de lister les instances d'un serveur. Elle fonctionne parfaitement avec SQL Server 2008 / 2008 R2 et 2005, mais j'ai un soucis avec la version 2000.
Voici la requête :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Set NoCount On
Declare @CurrID int,@ExistValue int, @MaxID int, @SQL nvarchar(1000)
Declare @SQLInstances Table (
InstanceID int identity(1, 1) not null primary key,
InstName nvarchar(180),
Folder nvarchar(50));
Insert Into @SQLInstances (InstName, Folder)
Exec xp_regenumvalues N'HKEY_LOCAL_MACHINE', N'SOFTWARE\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL';
Declare @Keyexist Table (Keyexist int)
Insert into @Keyexist
Exec xp_regread'HKEY_LOCAL_MACHINE', N'SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL';
Select @ExistValue= Keyexist from @Keyexist
If @ExistValue=1
Insert Into @SQLInstances (InstName, Folder)
Exec xp_regenumvalues N'HKEY_LOCAL_MACHINE', N'SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL';
Select serverproperty('ComputerNamePhysicalNetBIOS') as ServerName, InstName
From @SQLInstances
Set NoCount Off |
Et voici l'erreur retournée par SQL Server :
Code:
Impossible d'utiliser EXECUTE comme source lors de l'insertion dans une variable de table.
3 fois ce message d'erreur car j'essaye 3 fois d'utiliser un EXEC avec un INSERT INTO.
Connaissez-vous un moyen de contourner ce problème?