Skip to main content
Answer

How to remove all traces of a package from the SQL Database?

  • February 5, 2025
  • 1 reply
  • 38 views

Forum|alt.badge.img

We have a request from someone who would like an SQL backup of their data to give to an analyst to run Power BI on it.

We will be doing a backup in SQL Server Management Studio, and FTPing a .BAK file.

We don’t want them having access to any of the customizations that we have written and published. So, we need to remove them from the SQL Server database. 

Where do I need to go to scrub all of the published data. I know I need to remove any usr field we have added. I already have a script for that. I need the rest of it.

Just looking in the database file, I see:

CustProject which has a structure of:

      [CompanyID]
      ,[ProjID]
      ,[Name]
      ,[IsWorking]
      ,[Description]
      ,[CertificationStatus]
      ,[CertificationWarning]
      ,[CertificationStatusDateTime]
      ,[DevelopedBy]
      ,[Hash]
      ,[CreatedByID]
      ,[CreatedDateTime]
      ,[LastModifiedByID]
      ,[LastModifiedDateTime]
      ,[ParentID]
      ,[tstamp]
      ,[Level]
      ,[NoteID]
      ,[SnapshotID]
 

But that doesn’t contain all of the data. 

When I check for any matching NoteID, I also find the file:

SearchIndex

But that doesn't seem to contain the data either. So I think there is another file somewhere, but I can’t seem to find it.

Does anyone know?

Best answer by Django

I found this answer over at SO:

https://stackoverflow.com/a/45491758/9542263

https://stackoverflow.com/questions/45490932/does-the-customization-project-exist-in-the-database

This query will show you the files:

SELECT CustProject.Name as CustomizationProjectName, 
CustObject.Name as CustomizationItemName,
cast(UploadFileRevision.Data as varchar(max)) as TextFile,
UploadFileRevision.Data as BinaryFile
FROM CustProject
JOIN CustObject ON CustObject.ProjectID = CustProject.ProjID AND
CustObject.Type = 'File'
JOIN NoteDoc on NoteDoc.NoteID = CustObject.NoteID
JOIN UploadFile ON UploadFile.FileID = NoteDoc.FileID
JOIN UploadFileRevision ON UploadFileRevision.FileID = UploadFile.FileID AND
UploadFileRevision.FileRevisionID = UploadFile.LastRevisionID

 

1 reply

Forum|alt.badge.img+7
  • Captain II
  • Answer
  • February 5, 2025

I found this answer over at SO:

https://stackoverflow.com/a/45491758/9542263

https://stackoverflow.com/questions/45490932/does-the-customization-project-exist-in-the-database

This query will show you the files:

SELECT CustProject.Name as CustomizationProjectName, 
CustObject.Name as CustomizationItemName,
cast(UploadFileRevision.Data as varchar(max)) as TextFile,
UploadFileRevision.Data as BinaryFile
FROM CustProject
JOIN CustObject ON CustObject.ProjectID = CustProject.ProjID AND
CustObject.Type = 'File'
JOIN NoteDoc on NoteDoc.NoteID = CustObject.NoteID
JOIN UploadFile ON UploadFile.FileID = NoteDoc.FileID
JOIN UploadFileRevision ON UploadFileRevision.FileID = UploadFile.FileID AND
UploadFileRevision.FileRevisionID = UploadFile.LastRevisionID