Find Database User and Role

SELECT RoleP.name AS DatabaseRoleName ,ISNULL(UserP.name, ‘No members’) AS DatabaseUserName ,UserP.principal_id ,UserP.create_date FROM sys.database_role_members AS DRM RIGHT OUTER JOIN sys.database_principals AS RoleP ON DRM.role_principal_id = RoleP.principal_id LEFT OUTER JOIN sys.database_principals AS UserP ON DRM.member_principal_id = UserP.principal_id WHERE RoleP.type = ‘R’ and UserP.name = ‘my-name’ ORDER BY RoleP.name, ISNULL(UserP.name, ‘No members’);

Decode URL

CREATE FUNCTION dbo.UrlDecode(@url varchar(3072)) RETURNS varchar(3072) AS BEGIN DECLARE @count int, @c char(1), @cenc char(2), @i int, @urlReturn varchar(3072) SET @count = Len(@url) SET @i = 1 SET @urlReturn = ” WHILE (@i <= @count) BEGIN SET @c = substring(@url, @i, 1) IF @c LIKE ‘[!%]’ ESCAPE ‘!’ BEGIN SET @cenc = substring(@url, @i + … Read more

Encode URL

Version 2 CREATE FUNCTION dbo.UrlEncode(@url NVARCHAR(1024)) RETURNS NVARCHAR(3072)ASBEGIN DECLARE @count INT, @c NCHAR(1), @i INT, @urlReturn NVARCHAR(3072) SET @count = LEN(@url) SET @i = 1 SET @urlReturn = ” WHILE (@i <= @count) BEGIN SET @c = SUBSTRING(@url, @i, 1) IF @c LIKE N'[A-Za-z0-9()”*\-._!~]’ COLLATE Latin1_General_BIN ESCAPE N’\’ COLLATE Latin1_General_BIN BEGIN SET @urlReturn = @urlReturn … Read more

Transforming to an automated Database DevOps process

A Real-world Implementation of Database DevOps: People, Processes, Tools | Redgate (red-gate.com) For this implementation we will look at a team of professionals developing bespoke .NET solutions for their customers. Broadly, their ‘old’, manual database development, test and release processes looked like this. It used a shared development and test databases, a couple of ‘standalone’ … Read more

Reporting on actual transactions

When you approve a timesheet or expense, or invoice a contract in PSA, the business transaction is captured in the Actual entity. This entity can serve as the basis for almost all finance-related reports in PSA. The Actual entity captures the cost and sales transactions for the business event. It also captures many relevant attributes. When you’re working with … Read more

Reporting on resources

Project resources use the Bookable Resource entities from Universal Resource Scheduling (URS) that are shared with other apps, such as Microsoft Dynamics 365 Field Service. Here is a list of the entities that you might have to use when you report on project resources: