I have a view that returns users projects and also their windows login. An example of the data is below:
project | Login
------------------
project 1 | richab
project 2 | stevej
I need to append the domain to the login. I could put this in the code but i dont want to do that in every view I ever create that pulls users logins.
Can I create a global variable that I can reference in the views code. How can I achieve this? What’s best practice for this?
I don’t know if the SQL Server has global variables, but you can use a user defined function as follows:
and do a
SELECT dbo.fn_GetDomainName() + Login FROM table WHERE ...at the corresponding locations in your views.