Sample Header Ad - 728x90

SQL Server is not reading environment variable

0 votes
1 answer
1279 views
I want to create a CLR assembly, and here's my code:
use [master]
go

exec sp_configure 'show advanced options', 1
go

reconfigure
go

exec sp_configure 'xp_cmdshell', 1
go

reconfigure
go

execute sp_configure 'clr enabled', 1
go

reconfigure
go

execute sp_configure 'clr strict security', 0
go

reconfigure
go

declare @path varchar(256) = '';
declare @table table
(
	Value varchar(256)
)
insert into @table execute xp_cmdshell 'echo %CompanyProjectsRoot%'
set @path = 
(
	select top 1 Value 
	from @table
)
set @path = @path + '\Framework\Packages\Company.ClrIntegration.dll'
create assembly CompanyClrIntegration from @path
go
And I receive this error: > CREATE ASSEMBLY failed because it could not read from the physical file '%CompanyProjectsRoot%\Framework\Packages\Company.ClrIntegration.dll': 50(The request is not supported.). But if I change the path to absolute path C:\Copmany\Framework\Packages\Company.ClrIntegration.dll it works. And I know that %CompanyProjectsRoot% is already defined for the entire machine using this command: setx CompanyProjectsRoot C:\Company /m And I have also restarted SQL Server Management Studio. But still it does not expand environment variable. How can I fix this?
Asked by Ali EXE (215 rep)
Nov 18, 2021, 08:09 AM
Last activity: Nov 18, 2021, 01:22 PM