Thursday, May 31, 2018

How do I apply data mask to a column in a database table?

Here is what I am going to do.

Here is a query that retrieves FirstName, LastName, City from Employees table in the Northwind database on my SQL Server 2016 SP2 named instance OHANA.

Use Northwind
Go
SELECT FirstName, LastName, City
FROM Employees



Now I will apply a datamask to the FirstName column with a default() datamask using the following Alter Table, Alter Column statements.
-----------------------
Use Northwind
Go
Alter table Employees
Alter Column FirstName nvarchar(10) Masked with (Function='default()')

-----------------------------
When I run the above query, the query runs without errors. whenever I run the query, the data is not masked for me, because I have permissions.

To test the masking I create a user, hacker3 as follows:
--
/* create a hacker3 user*/
CREATE USER hacker3 WITHOUT LOGIN;
GRANT SELECT ON EMPLOYEES TO hacker3;
EXECUTE AS USER='hacker3'

----

DataMask_01

 Now I run a SELECT query, the same one we used earlier and get this response.


DataMask_02

You will observe that the FirstName column is masked. Note that the FirstNames in the table ranges from having 4 to 8 letters but the default() masking function replaces them with 3 xxx's.

Note that if you run a new query, you are not running as hacker3.


How does For..Break work in Python?

For loops through and at the first instance of a conditional match, it breaks and exits the loop.

Here is an example for a list in Python.


PythonFor_Break_0

The first two items in the list does not satisfy the condition and therefore you have two responses and when the program encounters 2 which is divisible by 2 (it's using modulo) the condition is satisified and it prints and then exits.

Here is the same in Visual Studio's Python interactive.


PythonFor_Break_1

Tuesday, May 29, 2018

What is Web SQL?

Web SQL is simply SQL database that you can run in the web. It is only supported in the latest version of Safari, Chrome and Opera. Web SQL database API  are used to work with client based databases. It is well suited for web applications.

The core methods are:

openDatabase
transaction
executeSql


openDatabase create a database aobject allows you to open an existing database or allows you to create a new one.

transaction allows you control transaction helping you to commit or rollback.

executeSql allows you to execute a Sql queries.

Firefox and Microsoft Edge does not support Web SQL since it is not going to be a W3C standard. However, Web SQL are wrappers for SQLite.

How do I format date data to remove the time data portion from it?

I have date coming from database as shown with time information really does not mean anything.


How do I clean up this column so that only date is shown.

Your original SELECT query is giving you this response.



You can use the Convert() function as shown here:

The syntax for Convert() function is as shown:

CONVERT(data_type(length), expression, style)

Underlying data type  datetime is converted to nvarchar(20) for the column Birthday using the Japanese Style (111).

Here is the style for USA:


Sunday, May 27, 2018

How do you place a checkmark in an image?

Checkmark symbol is more often used to place it in a checkbox to agree to something or answer the question yes or no, as in a license document.

Now if there is a checkbox in an image such as the one shown below how do you place a check mark in the checkbox, say Orders?
Select the Text icon in Paint as shown.



Checkmark_0.png

Place the cursor on the Orders' checkbox as shown.

Checkmark_1.png

Type in 2713 into the Text input area as shown.


Checkmark_2.png

Highlight 2713 in the checkbox and hit ALT Key and X at the same time.

You have changed the Unicode Hex to the symbol as shown.


Saturday, May 26, 2018

How do you know which columns are masked in a table?

If the table belongs to a database, then in the context of the database sun the query:

SELECT * FROM sys.columns

If the column(s) is masked you should look for the column 'is_masked' in the response as shown.


What is new in SQL Server 2016 Database Engine?

In SQL Server 2016,

Configure multiple TempDB database files during Installation and set up.
https://hodentekmsss.blogspot.com/search?q=TempDB

The Query Store (new) stored texts, execution plans and performance metrics with the database. You have access to its dashboard related to query performance.

https://hodentekmsss.blogspot.com/search?q=query+store
[image]

Availability of Temporal Tables (history) which records all data changes.
https://hodentekmsss.blogspot.com/2016/07/temporal-tables-in-sql-server-2016-to.html

Built-in JSON Support(new). You can import/export, save and parse in JSON.
https://hodentekmsss.blogspot.com/2016/11/accessing-nested-json-formatted-text.html

Polybase(new) query engine integrated SQL Server with external data in Hadoop or Azure Blob storage. Import/export and executing queries all possible.
https://hodentekmsss.blogspot.com/search?q=polybase

Stretch Database(new) lets you dynamically, securely archive data from local SQL Server Database to an Azure cloud SQL database. querying is automatic both local and remote data by linked databases.
https://hodentekmsss.blogspot.com/2016/05/stretch-database-is-nice-feature-of-sql.html

In-memory OLTP:
Now supports FOREIGN KEY, UNIQUE and CHECK constraints, and native compiled stored procedures OR, NOT, SELECT DISTINCT, OUTER JOIN, and subqueries in SELECT.
Supports tables up to 2TB (up from 256GB).
Has column store index enhancements for sorting and Always On Availability Group support.

New security features:
Always Encrypted: When enabled, only the application that has the encryption key can access the encrypted sensitive data in the SQL Server 2016 database. The key is never passed to SQL Server.
Dynamic Data Masking: If specified in the table definition, masked data is hidden from most users, and only users with UNMASK permission can see the complete data.

https://hodentekmsss.blogspot.com/2017/07/new-security-feature-in-sql-server-2016.html

Row Level Security: Data access can be restricted at the database engine level, so users see only what is relevant to them.

Friday, May 25, 2018

What are the choices for installing Reporting Services 2016?

The choices have not changed from previous versions.

During SQL Server 2016 Installation you can choose to specify Reporting Services Configuration mode.

There are two modes that you can specify Reporting Services Configuration:

Reporting Services Native Mode
Reporting Services SharePoint Integrated Mode


You can choose both modes or just one mode.

If you choose to install the Native mode there are two options:

Install and Configure
Install Only


Install and Configure option installs and configures the report server in Native Mode. However you need to do further configuration for your specific case. The Report Server is operaitonal with the Windows Service and the databases needed by Reporting Services in your named instance.

Install only installs the report server files. You need to use the RS Configuration Manager to compele configuration.

If you choose to install the SharePoint Integrated Mode you can only install the Report Server files but you will need SharePoint Central adminsitration to complete configuration.



Details for both modes of installation for SQL Server 2012 were described in my book:

ISBN 139781849689922
Paperback566 pages

Thursday, May 24, 2018

How do I chart US climate data with Excel?

You can ge the US climate data from this site.


It has data for all the states, like in this image.


USClimateData

This shows the data for Honolulu.


USClimateData_Honolulu

All you need to do is to highlight the data you want to use in Excel as shown,

Copy it.

Paste it into the first cell of an empty sheet.


Once it iss in EXCEL you can use the built-in functionality of charting data.

Wednesday, May 23, 2018

What data types can we use in a SQL Server 2016 database table?

Based on the table design using SQL Server Management Studio, v17.7, the following data types can be identified. These are the ones you find in SQL Server 17 as well.


Data types (text,ntext, image) continues to be present although Microsoft has been saying that they will be deprecated in a future version of SQL Server. 

Did Microsoft recently changed the icons for Keys of a table?

I don't know when this might have happenned, Microsoft certainly seems to have changed the icons for Primary and Foreign keys in the Object Explorer of SQL Server Management Studio.

Here are examples from a previous version (SQL Server 2012 Express and the SSMS 2012).



Here are the same tables in the latest version SQL Server 2016 SP2; SQL Server Managment Studio Version 17.7.


The new keys lacks color, but it is better than the ones in previous version. The opposing directions are suggestive of the way they work.

Tuesday, May 22, 2018

How come I cannot create a New Database Diagram in SQL Server 2016 SP2?

I restored a copy of Northwind Database to a SQL Server 2016 Developers edition's named instance and I get this message.


NewDBDiagram_0

When I access the help on the above message, I display the following:


NewDBDiagram_1.png
II click 'Yes' without placing a check mark and I get sent to this site:

https://productforums.google.com/forum/#!topic/adsense/lcXY_ahp60M

The Microsoft support on this page does not seem to help unless you can search through this whole site. That's a joke!

I did not have this kind of experience earlier.

Monday, May 21, 2018

Can you connect to PowerShell from SQL Server Management Studio 17.7?

PowerShell is very well supported in SQL Server and it is true with the latest version as well.

What you begin with in Power Shell depends on from where it is invoked in the SQL Server Management Studio.

You can invoke (or start) PowerShell from various objects and it will be contextual in relation to the object.

If you right click the Server as shown you poup-up a mneu from which you can access PowerShell as shown.


PS_0

When you click Start PowerShell, the PowerShell window gets displayed as shown.


PS_1


Similarly the next image shows PowerShell being invoked in other contexts.

PS_2

These are not the only objects to invoke PowerShell, many more objects can be used to invoke PowerShell contextually.

Once you get to the object you want to review, the database can be accessed like folder/files using windows commands as shown.


PS_3

Read many more related PowerShell posts here.

Sunday, May 20, 2018

How do you register a SQL Server in SQL Server Management Studio v17.7?


When you have a large number of SQL Servers it becomes a no brainer to find a way to manage them effectively. SQL Server Management Studio can be very effective in managing local servers by grouping them according to your usage necessities.

Registering SQL Server instances makes it easy to administer. Connecting to servers is a lot faster if you register all the instances in the Local Group of Servers. In SQL Server Management Studio 17.7 it is lot easier to register than in previous, older versions.

I have three SQL Server instances from 3 different versions. After registering I just need to double click the server I am using and I am ready to roll.


Watch the Video:
https://youtu.be/eWkbcBgjq80

Wednesday, May 16, 2018

How do you recognize the version of SQL Server you want to install?

There have been many versions of SQL Server released over a long period of time and of course these are followed up by Service Packs (SP). It is hard to know which version is going to be installed.

There is an unofficial chart lists of all the known SP;s, Cumulative Updates(CU), patches and hot-fixes from SQL Server 7.0 to SQL Server 2017.

SQL Versions.png

Read here: https://sqlserverbuilds.blogspot.com/

I have a reasonably latest version of SQL Server 2016 Developer edition:
Microsoft SQL Server 2016 (SP1-GDR) (KB4019089) - 13.0.4206.0 (X64)   Jul  6 2017 07:55:03   Copyright (c) Microsoft Corporation  Developer Edition (64-bit) on Windows 10 Pro 6.3 (Build 17134: ) (Hypervisor) 

The following version download is here:
13.0.5206.0 4/9/2018--> SQL Server 2016 SP2
https://www.microsoft.com/en-us/download/details.aspx?id=56836

Sunday, May 13, 2018

Are these Blogger stats to be believed?

In my previous post, I described the discrepancy in view statistics within the Blogger posts ().
While the previous post was within a single, one time instance of the blogpost here are images at two different times of the same blog and the analytics.

May 5, 1:00 PM


May 5, 5:00 PM


I am sure there is an explanation and I hope Google can explain this and the discrepancy in my previous post.

Saturday, May 12, 2018

What is the latest version of Report Builder 3?

I believe the latest build of Report Builder 3 is version 14.0.1016.246 published 2/16/2018 (23.0MB). I had this earlier version 14.0.344.82 published 3/9/2017 (22.6MB).

Go to this link and download the latest Report Builder 3

https://www.microsoft.com/en-us/download/details.aspx?id=53613

If you all ready have Report Builder 3 (earlier version) you will be asked to repair or remove.
Accept 'Repair option and click Next to Install.

This is the program created on your computer.


Thursday, May 10, 2018

How do you create a JSON object?

You go by definition of a JSON Object. JSON Object components are placed under curly braces as shown here.

{"name1":"value1","name2":"value2","name3":"value3"}

Here is an example:

var JSONObj = {"Fname":"Jay","LName":"Krishna","Hobby":"Blogging"};

JSON object consists of name/value pairs separated by commas.

In the above names are:
Fname, LName and Hobby

The corresponding values are:
Jay, Krishna and Blogging

Here is an HTML file that writes the values of a JSON object to the browser.

You can upload it to your website (perhaps IIS's Localhost). When you browse to it you get this response.



For a more detailed article go here:

Wednesday, May 9, 2018

How to work with trignometric functions in Python 3.7?

You need to import math module to do anything with trigonometric calculations using Python.

Hence the first thing to do trigonometry in Visual Studio is to have this first line in the interactive Python code window. We will use the Python Interactive in Visual Studio 2017 Community described in a previous post.

The above image also shows the basic use of degrees and radian measures. The value of PI, math.radians and math.degrees are most useful as they are the basis.

Here is a list of all trigonometry related functions that you can access in Python 3.7.

You get help in Visual Studio 2017 similar to intellisense as shown here.


Text in red is error message. pi is not defined, only math.pi is defined.

Here are some trigonometric functions evaluated.

There are a few more such as math.hypot().







Tuesday, May 8, 2018

How do you use Interactive Python in Visual Studio 2017 Community?

Visual Studio provides access to Interactive C#, Python and F#. We have already seen how to use C# interacitve in visual Studio.

Herein, we will start Python Interactive in Visual Studio 2017 Community IDE.

Launch Visual Studio 2017 Community from All Programs (look under V).


PythonInterA_0.png


Click Start and in the start Window click View | Other Windows as shown. You will see all interactive programs that you can use in Visual Studio.


PythonInterA_1.png

Click Python Interactive. Python 3.7 (x32) opens as shown.


PythonInterA_2.png

Enter some simple calculation to start with and note that intellisense-type feature is available as long as the DB is current.

PythonInterA_3.png


You can see the result as shown.

PythonInterA_4.png

$help command opens the help file and keyboard shortcuts as shown.



PythonInterA_5.png
That is all...