SSAS : How to generate a csv of all the users having access to a cube? - sql

I need to compare the users listed in a file with the users having access to a certain cube to check which to add and which to remove so it checks out. Problem is, there are about 1000 users, so I'm not gonna be able to do it one by one. Is there a quick way to generate a CSV of all the users of the cube so I can work some Python magic and get the overlap / difference easily ?

Connect to the Cube Server via SSMS.
Expand your cube
Expand "Roles"
Right Click on "ReadOnly" >> "Script Role as" >> "CREATE TO" >> "New Query Editor Window" or "File..."
Now you have a XML-File containing all the Users with access to your cube (One comment: if you/ your server admin are working with security groups and you don't have the rights to look into those security groups, then you need to reach out to him, so that he/she can give you the list of members of this security group).
If you are not so much into querying XML-Files, here is a pretty simple workaround of how to get your list:
- Go to your favourite Editor (Notepad++, etc.) and remove everything except the lines with < Name >.
In Notepad++ that can easily be done by highlighting lines with "< Name >" (Press Search STRG+F, then go to highlight and activate "Set Bookmark")
then go to "Search" >> "Bookmark" >> "Remove all lines without Bookmarks"
Finally Search and Replace "< Name >" and "< / Name >" with "".
Now you have your list without annoying XML-Content, which you can for example paste into Excel and compare it via a vlookup with your list or better: you insert both list in sql tables and compare them via sql

Related

SQL Server Management Studio (SSMS) - assign hot key for command - filter table

I have thousands tables in a data base, and if I need to find table I should find the tables' folder in the Object Explorer than click right mouse button on it and then select menu Filter -> Filter setting and after that I can input name of the table.
How can I assign hot key exactly for this command?
PS: I know how to assign hot keys in SSMS, I can't find filter table command.

How do I transfer a schema and all of its tables to a new database?

I have database a with schema foo which contains 20 tables. I want to move all of the contents of schema foo into database b without overriding the current content in database b.
Is there also a way to do it in pgadmin?
I found this link and perhaps it will be quite similar. But this particular link is for transferring a table.
Copy a table from one database to another in Postgres
You can script the first database with all its data once scripted you can run the th script within the other database it should work as long as you dont have tables in the second database with the same name
so in pg admin follow these steps to script the
-Right click on the database and click Backup.
-Selece a filepath and filename on where you want to save your script
-Select Plain as the format in the format dropdown.
-Go to Options and check "schema and data" in tab # 1.
-Then click on Backup.
-Then click Done.
-Then right click on your 2nd database and create a new query.
-Find where you saved the script and copy the script to the query
-run the query and should be all good
if you are unsure about this just create 2 practice databases and practice on those before you do it on the main one

ssms -- how to create table same as table on another server without data

I need to create a table similar to the one on another server.
How can I do this using ssms?
I am able to copy table from one server to another with data using Tasks | Export data but not sure how to create without data.
Right click on the database you want the shell of in the SSMS gui.
Choose Tasks ---> Generate Scripts
There is a glossary of sorts on the left side of the panel
Under Introduction: Choose Next
Under Choose Objects: (1)Check Select Specific Objects. (2) Expand the "Tables" section. (3) Check the table(s) you want to generate.
Under Set Scripting Options: (1)Choose Save to File.
(2) Set the Destination Drive and location.
(3) Click Advanced
There are lots of options under advanced start with these two, you may need to adjust others, but not likely.
(1) Script for Server Version - Set to the server version you will be restoring the empty database, OR the same version as the source database.
(2) Types of data to script - Choose Schema Only
Click OK
Click Next
Click Next
Should get all green icons on success.
Click finish.
Go to Destination database, open your file, execute the query.

How to connect an Excel file to an Access Database

I have created a query in an Access database and exported the query result into an Excel file. Now, I want to connect that Excel file to the Access database (or to that query) so that whenever some fields are updated in database, those changes would be automatically updated in the exported Excel file (report). What would be the best way to do it?
Thanks
You can create a link between Excel and an Access table or query by going to the Data tab on Excel and clicking the "From Access" icon.
Alternatively if there is a trigger inside access that you can use to update data (or if you don't need real time updates just hourly or daily ones), you could have access programmatically re-export.
If you want to work with data in Access, but still maintain the data in Excel, you need to link to the data rather than import it. Follow these steps:
Create a blank database or open an existing file in Access.
Select File, Get External Data, Link Tables.
Select Microsoft Excel as the file type.
Select a worksheet or named range to import, and then
click Next. You can import only one worksheet or named range at a
time, and each one will become an Access table.
In the next dialog box, select or deselect the check box First Row
Contains Column Headings, depending on whether your worksheet has
headings. Then click Next.
Enter a name for the table (or accept the default name that Access
suggests), click Finish, and click OK.
Now you have an Access table that looks almost exactly like the imported table. The advantage is that it maintains a live link to the Excel worksheet and can be edited in either application.

Change the text of Power Query using vba

I've a situation when by click on the button a Power Query text must be updated.
So what is needed to be done:
take the data that user provided as a files location and file names (no problem with that)
send to Power Query new location and file names, refresh the Query.
As I've seen, only Refresh is vba-described...
Does somebody have the information on how the text of Power Query could be modified?
It's supported in Excel 2016 and later: https://gallery.technet.microsoft.com/office/VBA-to-automate-Power-956a52d1
Use the Workbook.Queries property to change the text.