Azure Course Labs

Lab Solution

Using SSMS on the SQL VM, create a new login with a strong password with the CREATE LOGIN statement:

CREATE LOGIN labs2   
   WITH PASSWORD = '00234$$$jhjhj' 
GO  

The SQL VM is already configured for public access, so you can connect. If you try to use the UDF:

SELECT dbo.LegacyDate() 

You’ll see an error:

The EXECUTE permission was denied on the object ‘LegacyDate’, database ‘master’, schema ‘dbo’

So back in the VM you need to grant object permission - but permissions are granted to a user, so you need to create a user for your login first:

CREATE USER labs2 FOR LOGIN labs2

GRANT EXECUTE ON LegacyDate TO labs2

Now in your remote session you can execute the UDF.