SQLTeam.com | Weblogs | Forums

DLL Path in Variable for Create Assembly


#1

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.


#2

Are you running it in sqlcmd mode?


#3

Hi,
Yes i'm running in sqlcmd modus

Thanks
Pit


#4

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

I added single quotes.


#5

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;

#6

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.