Wednesday, 18 April 2018

How to unlock a locked account in sql server?

You tried to login a user and have this message / error:

The account is currently locked out. 




Solution:
Step 1: Login to sql server as Administrator

Step 2: Security >> Logins >> right click the user >> click Properties >> select Status page





Uncheck Login is locked out. and click Ok.

It will ask for "Reset password for the login while unlocking".

We need to go to General page and give password and Confirm password.

Click Ok.

Monday, 16 April 2018

GIT Repository update via Visual Studio 2015

Using the Visual Studio Enterprise 2015 for repository update regarding database projects, usually need to compare the database schema and then commit the changes to remote.

The steps are

1. Connect the project from Team Explorer
2. Git Flow >> Create Feature and give the feature a name / tag.
3. Solution Explorer >> right click the solution and select Schema Compare
in Schema Compare screen [Compare] we have Source and Targets Schema. select the objects and click [Update].
4. in Team Explorer GitFlow select Finish Feature.

Wednesday, 11 April 2018

How to check if a table is exist or not?

The following are queries to check the object / table exist or not before create / drop in Sql Server.

 IF OBJECT_ID('dbo.temp_data') IS NOT NULL
       BEGIN
            execute (N'DROP TABLE [dbo].[temp_data]')
        END

    IF OBJECT_ID('dbo.temp_data') IS NULL
BEGIN
       CREATE TABLE [dbo].[temp_data](
                [no] [int] NULL,
                [empname] [varchar)100)] NULL,
                [empDept] [varchar(100)] NULL,
                [empLocation] [varchar(100)] NULL
            ) ON [PRIMARY]
        END

Wednesday, 14 March 2018

How to query SSIS jobs information from SQL Server

Query to find the SSIS jobs data in MS SQL Server.

WITH ChildFolders
     AS
     (
         SELECT PARENT.parentfolderid,
                PARENT.folderid,
                PARENT.foldername,
                CAST('' AS SYSNAME)  AS RootFolder,
                CAST(PARENT.foldername AS VARCHAR(MAX)) AS FullPath,
                0                    AS Lvl
         FROM   msdb.dbo.sysssispackagefolders PARENT
         WHERE  PARENT.parentfolderid IS NULL
         UNION ALL
         SELECT CHILD.parentfolderid,
                CHILD.folderid,
                CHILD.foldername,
                CASE ChildFolders.Lvl
                     WHEN 0 THEN CHILD.foldername
                     ELSE ChildFolders.RootFolder
                END                   AS RootFolder,
                CAST(
                    ChildFolders.FullPath + '/' + CHILD.foldername AS VARCHAR(MAX)
                )                     AS FullPath,
                ChildFolders.Lvl + 1  AS Lvl
         FROM   msdb.dbo.sysssispackagefolders CHILD
                INNER JOIN ChildFolders
                     ON  ChildFolders.folderid = CHILD.parentfolderid
     )
SELECT F.RootFolder,
       F.FullPath,
       P.name         AS PackageName,
       P.description  AS PackageDescription,
       P.vermajor AS MajorVersion,
       P.verminor AS MinorVersion,
       P.verbuild AS BuildNumber
FROM   ChildFolders F
       INNER JOIN msdb.dbo.sysssispackages P
            ON  P.folderid = F.folderid
WHERE  P.name IN (
            'HR_Job',
            'Accounting_data_upload',
            'data_for_webshop',
            'data_to_warehouse',
            'data_from_branches'
            )
ORDER BY
       F.FullPath ASC, P.name ASC;

How to unlock a locked account in sql server?

You tried to login a user and have this message / error: The account is currently locked out.  Solution: Step 1: Login to sql ser...

Popular