Wednesday, July 19, 2017

Regarding ntext, nchar and nvarchar

These are basically used for textual information related data types. There is a strong recommendation not to use ntext as it is not going to be supported.

These are their definitions from Microsoft Documentation.

ntext (National Text):
Variable-length Unicode data with a maximum string length of 2^30 - 1 (1,073,741,823) bytes. Storage size, in bytes, is two times the string length that is entered

nchar [ ( n ) ]
Fixed-length Unicode string data. n defines the string length and must be a value from 1 through 4,000. The storage size is two times n bytes. When the collation code page uses double-byte characters, the storage size is still n bytes. Depending on the string, the storage size of n bytes can be less than the value specified for n. The ISO synonyms for nchar are national char and national character..
1
nvarchar [ ( n | max ) ]
Variable-length Unicode string data. n defines the string length and can be a value from 1 through 4,000. max indicates that the maximum storage size is 2^31-1 bytes (2 GB). The storage size, in bytes, is two times the actual length of data entered + 2 bytes. The ISO synonyms for nvarchar are national char varying and national character varying.

ntext is supposed to be discontinued, but in actuality it is still present as a choice in data types listing even in SQL Server 16.


Sunday, July 16, 2017

Restoring the Northwind database from its backup

A backup of Northwind database was obtained from the Codeplex site and was saved to one of the folders on a Dell computer with Windows 10 OS. The computer also has SQL Server Management Studio (v 17.1). You should be able to restore using the SQL Server Management Studio installed when you installed the SQL Server 2012 Database engine.

Follow these steps to restore the Northwind database to an instance of SQL Server 2012 (x86) installed on the same computer.

Step 1. Start SQL Server Management Studio v17.1 (Run as administrator)

The SSMS is version 17.1 and Hodentek9\PCATT is a SQL Server 2012 Express

Step 2. Right click the Databases node highlighted in the PCATT isntnace as shown.




RestoreDB_01

Step 3: Click Restore Database...

Restore Database window is displayed as shown.


RestoreDB_02

Step 4: The Default Source is Database and it is greyed out as shown. Chnage it to Device. The Restore Database gets changed as shown.


RestoreDB_03

Step 5: Click the ellipsis button along 'Device' in the above image.

Select backup devices window shows on top of Restore Database window as shown.


RestoreDB_04

Step 6: Click Add button in Select backup devices window.
Locate Backup File window gets displayed as shown.


RestoreDB_05

Usually the 'backup files with extension .bak' are found in the following directory in the case of x32 bit SQL Server.
C:\Program Files (x86)\Microsoft SQL Server\MSSQL11.PCATT\MSSQL\Backup

However, for this exercise it is stored in a different location.

Step 7: Now browse to that location and highlight the Northwind.bak (A backup file which came from a Microsoft site) as shown.


RestoreDB_06

Step 8: Click OK. The file path is entered in the Select backup devices window as shown.


RestoreDB_07.png

Step 9: Click OK
You are returned to the Restore Database - Northwind as shown.


RestoreDB_08.png

Step 10: Click OK in the above.

Microsoft SQL Server Managment Studio message reports that the database
'Northwind' restored successfully.


RestoreDB_09.png

Step 11: Click OK to the message. Verify that Northwind database is in the SQL Server 2012 instance Hodentek9\PCATT


RestoreDB_10.png


Bye



Saturday, July 15, 2017

Microsoft SQL Server Management Studio 17.1 is generally available

SSMS Version 17.1 became available in June 2017 and you may want to downladd and install. This version will work with all editions of SQL Server so far (2018 to 2017). However some of the older applications written using older versions may still need older versions of SQL Server Management Studio.

Download the latest version of SQL Server Management Studio (version 17.1) here:

https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms

If you had had SSMS version 17.0, you may get a notification as to availability of version 17.1 which should facilitate installing the new version.


You need to restart after installing.




These are the enhancements in this version:

  • Profiler: Help > About now displays release version number (e.g 17.1)
  • Analysis Service users can refresh credentials for their datasources for 1200 TM models and above from the context menu on the datasource
  • Built-in SSIS reports now show logs from SSIS scale-out execution in CTP 2.1
  • SSIS scale-out management application
             View basic information about scale-out master.
             Easily add a Worker to the scale-out deployment.
             View all the scale-out workers and basic information about them, and can also enable or disable them easily.

This version will also have toast notifications when new updates are available. It also has a new stand alone web installer.

Friday, July 14, 2017

New security feature in SQL Server 2016: Dynamic Data Masking

Dynamic Data Masking which is available in SQL Server 2016 allows you provide another level of security to your data, by masking data that you do not want unauthorized (by policies) users to peek into. Data in the database itself is unchanged. SQL Server 2016 has other security features besides dynamic data masking.

Data leaks and hacking has become too common place. SQL Server 2016 provides yet another way to protect data by this new feature, Dynamic Data Masking (DDM).  Developers and administrator should (must) use this feature to mask data from intentional prying eyes.

DDM is a nice feature that you should implement if are dealing with sensitive information (Credit card numbers, Social Security Numbers, etc).

Here is an image of credit card numbers being masked (perhaps not by DDM in this view)



Credit card masking imaged source: http://www.gsapps.com/images/masking2.gif

Read here about masking using JavaScript:

https://stackoverflow.com/questions/25367230/masking-a-social-security-number-input

Do you need special permission to create a table with a dynamic data mask?

No, you do not. Of course you need standard permissions like Create table, Alter on schema permissions.

The Alter Any Mask permission and Alter permission on  a Table are needed, though.

Read more about Dynamic Data Masking here:
https://docs.microsoft.com/en-us/sql/relational-databases/security/dynamic-data-masking

Friday, July 7, 2017

SQL Server 2012 Express(x86) is not registered in the Local Servers Groups by default

Although you can connect to SQL Server 2012 Express (x32bit) from SQL Server Management Studio (Version 14.0.17099.0), the Express Server does not belong to the Local Servers Groups by default as shown.




Thursday, July 6, 2017

SQL Server 2012 (x86) and SQL Server 2016 Developer on the same x64 bit computer

The short answer is YES.

A x32 bit SQL Server Express Advanced and a x64 bit SQL Server 2016 SP1 are both installed on a Dell Inspiron laptop.

Here are the responses to the command:

SELECT @@version in a query launched by both of these versions:

(No column name)
Microsoft SQL Server 2012 - 11.0.2100.60 (Intel X86)   Feb 10 2012 19:13:17   Copyright (c) Microsoft Corporation  Express Edition on Windows NT 6.2 (Build 9200: ) (WOW64)

(No column name)
Microsoft SQL Server 2016 (SP1-GDR) (KB3210089) - 13.0.4202.2 (X64)   Dec 13 2016 05:22:44   Copyright (c) Microsoft Corporation  Developer Edition (64-bit) on Windows 10 Pro 6.3 (Build 15063: )

They can co-exist as shown:



Wednesday, July 5, 2017

Get July version of Microsoft Power BI Desktop

The July 5 version of Microsoft Power BI Desktop can be downloaded from here:

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

The details of this version  are here


Summary of new/improvements:
Reporting
    New table & matrix visuals are now generally available
    Renaming fields in visuals
    Custom visuals store integration
    Relative date filters
    Responsive layout for visuals (preview)
    New waterfall chart option - breakdown
    Custom visual updates
        Drilldown Choropleth
        Drilldown Cartogram
        Drilldown Player
        Certified custom visuals

Analytics & modeling
    Quick measures from the community
        Star rating
        Concatenated list of values
    Bidirectional cross filtering for DirectQuery is now generally available

Data connectivity
    Snowflake connector general availability

Query editing
    Add Column from Examples enhancements

Watch the video for new feature details: