Flipkart

Showing posts with label MS SQL. Show all posts
Showing posts with label MS SQL. Show all posts

Friday, August 30, 2019

Check SQL Server system Date and Time


Using below commands you can check SQL server date and time.

Open query browser and type the following commands. And when you execute it output will come out.

Command : 1

Select CURRENT_TIMESTAMP;


Command : 2

Select SYSDATETIME();



In below Results column its show the current Date and Time.


Current TIME in Various Formats
Below are the examples of current TIME in various formats:

  1. Current TIME in the 24-hour format hh:mi:ss

SELECT CONVERT(VARCHAR(8), GETDATE(), 108) 'hh:mi:ss'


  1. Current TIME in the 24-hour format hh:mi:ss:mmm

SELECT CONVERT(VARCHAR(12),GETDATE(),114) 'hh:mi:ss:mmm'


  1. Current TIME in the 12-hour format hh:mi:ss:mmmAM

SELECT RIGHT(CONVERT(VARCHAR(26), GETDATE(), 109),14)
          'hh:mi:ss:mmmAM (or PM)'


Tuesday, December 18, 2018

How to Enable SA Account in SQL Server 2014

    clip_image001

    backup failed for server (microsoft.sqlserver.smoextended)

    Enable the sa Login:

    1. Connect to the SQL Server instance using SSMS and go to Security. Expand Security, go to Logins.

    2.  You can see the sa account is disabled when you install SQL Server using Windows Authentication mode.

    clip_image002

    3. Right-click on the sa account and go to Login Properties

    clip_image003

    By default, the Enforce password policy is checked. (if you don’t want to provide a complex password for the sa account, you can uncheck this option. However, this is not recommended.)

    4. Click on the Status page. By default, the sa account will be disabled. Click on the Enabled button to enable the sa account. Click on Ok to close the sa Login Properties.

    clip_image004

    sa account is enabled and you will be able to login to the SQL instance using the sa account.

    Method 2:

    Enable SQL Server SA Account with Script

    1. Login into SQL Server using Windows Authentication mode and open Management Studio.

    2. Click "New Query" to create a query, and type followings:

    USE [master]

    GO

    ALTER LOGIN [sa] WITH PASSWORD='password'

    GO

    ALTER LOGIN [sa] ENABLE

    GO

    Method 3:

    1. In SQL Server Configuration Manager, in the left pane, select SQL Server Services. In the right-pane, find your instance of SQL Server. (The default instance of SQL Server includes (MSSQLSERVER) after the computer name. Named instances appear in upper case with the same name that they have in Registered Servers.) Right-click the instance of SQL Server, and then click Properties.
    2. On the Startup Parameters tab, in the Specify a startup parameter box, type -m and then click Add. (That's a dash then lower case letter m.)
    3. Click OK, and after the message to restart, right-click your server name, and then click Restart.
    4. After SQL Server has restarted your server will be in single-user mode. Make sure that that SQL Server Agent is not running. If started, it will take your only connection.
    5. On the Windows 8 start screen, right-click the icon for Management Studio. At the bottom of the screen, select Run as administrator. (This will pass your administrator credentials to SSMS.)

Sunday, October 7, 2018

How to upgrade MS SQL 2014 to SQL 2017

Download the required version.

https://www.microsoft.com/en-us/sql-server/sql-server-editions-express

clip_image001

clip_image002

The Installation Wizard starts the SQL Server Installation Center. To upgrade an existing instance of SQL Server, click Installation in the left-hand navigation area, and then click Upgrade from... previous versions of SQL Server.

clip_image003

Accept the license agreement.

clip_image004

Here you can choose to allow Microsoft updates to pull updates for SQL as well.

clip_image005

In the specify the instance of SQL Server to modify you can choose a specific instance, or in the dropdown combo box, you can also choose to only upgrade shared components.

clip_image006

With the upgrade, it is not possible to change the configured features currently configured by SQL Server 2014.  By default it will upgrade all configured features.

clip_image007

Here you can specify the instance ID for the instance of SQL Server.

clip_image008

Here you can specify the service accounts and collation configuration.

clip_image009

As you can see there are three choices here – Import, Rebuild, and Reset.  Since this was a clean installation of SQL Server 2014 that was being upgraded to SQL Server 2016, I chose to Rebuild full-text catalogs using the new and enhanced word breakers.  As the installation notes below, rebuilding indexes can take a while, and a significant amount of CPU and memory might be required after the upgrade.

clip_image010

Finally, we come to the Ready to Upgrade screen that displays our configuration choices.

clip_image011

After the upgrade process has completed, you are notified that you need to reboot the server to finish out the process.

clip_image012

You should see Succeeded on all the individual upgrade steps.  If not, take a look at the setup log for the upgrade process to begin troubleshooting.

clip_image013