DLL Path in Variable for Create Assembly

Hi,

i try create Assembly from a DLL

this works:

CREATE ASSEMBLY [MyAssembly]
AUTHORIZATION [dbo]
FROM 'c:\temp\mydll.dll'
WITH PERMISSION_SET = EXTERNAL_ACCESS;

How can i make this something like:

CREATE ASSEMBLY [MyAssembly]
AUTHORIZATION [dbo]
FROM [$(MyDLLPath)]
WITH PERMISSION_SET = EXTERNAL_ACCESS;

If i try
:SETVAR MyDLLPath "C:\TEMP\MyDLL.dll"

it give me an error and says me, c:\temp\mydll.dll ist not right in this context. Wrong Syntax near the WITH Keyword

How can i give a variable PathName?

Thanks.

Are you running it in sqlcmd mode?

Hi,
Yes i'm running in sqlcmd modus

Thanks
Pit

Try this: :SETVAR MyDLLPath "'C:\TEMP\MyDLL.dll'"

I added single quotes.

I hadn't thought of that. Stared at this for a few minutes and couldn't figure out what it should be. The other thought that occurs is that perhaps this would be what is required. (I am of course guessing with nothing to back it up :smile:

:SETVAR MyDLLPath "C:\TEMP\MyDLL.dll"

CREATE ASSEMBLY [MyAssembly]
AUTHORIZATION [dbo]
FROM '[$(MyDLLPath)]'
WITH PERMISSION_SET = EXTERNAL_ACCESS;

Hi,
thanks for you answers.

Now it work's :slight_smile:

:SETVAR MyDLLPath "C:\TEMP\MyDLL.dll"

CREATE ASSEMBLY [Assembly]
AUTHORIZATION [dbo]
FROM '$(MyDLLPath)'
WITH PERMISSION_SET = EXTERNAL_ACCESS;

Have a nice day.

1 Like