This is something that I forget 2 seconds after I’ve used it so now I’ll put it here as a note to self.
I have a series of TSQL scripts that I use once in different circumstances and often it’s a while between each go. In some of the I need to add some environment specific information and instead of having to scroll down through the text the query editor offers a way of prompting for parameters through a tagging of text like this:
select <Parameter name, Data type, Default value>
Before executing the script you press CTRL+SHIFT+M (this is the part I usually forget) and that makes the editor prompt you like this:
Replace the Default value with the appropriate text and click OK. This will update your SQL script to this:
Not the most mind-blowing thing in the world, but a great help.
While testing MPOS changes I had to do an uninstall on my laptop. But every time I tried to uninstall it told me that there was an error and it couldn’t complete the uninstall and that I should contact the administrator.
And then it reappeared in the list of installed apps.
Trying to run the Uninstall-RetailModernPOS.ps1 gave a hint of what’s wrong:
You’ll usually find the script around here:
C:\Program Files (x86)\Microsoft Dynamics 365\70\Retail Modern POS\Tools\
There might be some clever way of fixing this, but in order to move forward I did a quick’n’dirty and not recommended way of fixing it:
Remove the check …
Edit the script by commenting out this line:
This is not recommended and definitely not in a production environment and I do not take any responsibility for any undesired outcome of this. But it did the trick for getting me forward.
Please note, that this doesn’t take away the error. So when you uninstall the next time it’ll still throw the error at you until you once again remove the check.
Ok, this is not exactly AX but it IS in the category of related to. The thing is that you sometimes needs to take a backup of a database or other stuff on the SQL server and sometimes you need to either do this repeatedly every once in a while, have somebody else trigger it or simply document what you did.
Microsoft SQL Server Management Studio offers a lot of nice UI to handle processes like backup, restore and index manipulation. And it is so much easier to do it here than trying to write it in a query window. But it can be a pain remembering – I mean documenting – every option set and redo these settings every time. So this often forgotten feature in most of these UI elements in the Management Studio could come in handy.
After doing all the setup of e.g. the backup process you can use the Script button in the upper left-ish corner:
We are now offered 4 different ways of getting our script including short cuts for us to remember. The top three gives us the script in respectively a query window, a file or in the clipboard:
Now you can combine multiple scripts into one if you would like to for example backup one database and restore it over another by
Create the script for the backup in a query window
Create the script for the restore in the clipboard and paste it in query window with the backup
Do whatever you need to do with the full script to backup/restore
The 4th possibility is to get the script to be a step in a new job if you need to repeat the script on for example a daily basis. Select the Script Action to Job:
From here you just need to set up the schedule and you are ready to go.
The script is added to Step 1 so you can manipulate it or just see what is being executed.
Remember that firing scripts directly on the SQL-server or through other clients can be extremely powerful and dangerous and can have fatal effects on the server and databases. So whatever you do … be carefull out there …