Remove the ‘Domain\’ portion from your SSRS User!UserId Variable

If your lower environments feature a different domain name to production, there could be a requirement to remove the ‘DOMAIN\’ portion of the string that is returned by the Reporting Services User!UserId report collection value.

The following code segment demonstrates how this could work in a stored procedure that uses this variable as a parameter.

DECLARE @Username varchar(100)

SET @Username = 'DOMAIN\Billy.Bob'

SELECT @Username AS Before, RIGHT(@Username,LEN(@Username)-CharIndex('\',@Username, 1))AS After

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s