Skip to main content

Posts

Showing posts from 2015

Problem of 1 (one) Unread Email in the Default Windows Mail App in Windows 10.

Some users have noticed the problem of 1 (one) unread email in the Windows Mail App in Windows 10, even though there is no unread email in the account. In order to resolve this, do the following: a. Select the account in the Windows Mail App in which the problem of unread email is showing up. b. Select the first email in that account. c. Then in the right hand side from the top, choose, mark it as unread. d. Then again choose mark it as Read. It will resolve the issue. I don't know the logical reasoning of the same, but it works for me.

RealTek Sound Driver Installation Hang Problem in Bootcamp Installation on Windows 10.

I faced a problem of installing the bootcamp drivers on Windows 10 on a MACBookPro Mid 2012 Model. I tried a number of things, but it always hang at the installation of the RealTek Drivers. I followed the resolution given below and it worked for me: a. Remove the folder of RealTek Drivers from the BootCamp Folder. b. Now re-run the installation again. c. BootCamp will automatically install the drivers for Sound and other things. d. Reboot your MAC. The boot camp drivers are functioning properly.

SQL Server Database in Single User Mode

In SQL Server, some times the database is put into the Single User Mode for different reasons and it will appear like: YourDatabaseName (Single User) In order to get it into multi user mode, we can use the following command: Use Master Alter database set Multi_user In case we get an error of "Database currently in use". Then we can use the following command to kill the connections and run the above command again. exec sp_who We need to find the spid of the database for which we want the multiuser mode. Use the following command to kill that process: kill After the above command, we can run the command: Alter database set Multi_user The database will be in the multiuser state. Just refresh the whole SQL Server Browser Tree. Update: Even after trying out the steps given above, if the database is not restored, use the following commands: a. Put the database in offline mode. alter database set offline with rollback immediate b. No

SQLServer Error: 15404, Could not obtain information about Windows NT group/user Error code 0x5. [SQLSTATE 42000] (ConnIsLoginSysAdmin)

If we encounter this error "SQLServer Error: 15404, Could not obtain information about Windows NT group/user Error code 0x5. [SQLSTATE 42000] (ConnIsLoginSysAdmin)" in SQL Server in which the job fails because of the user account related problem, then we need to take the following steps to make it work: a. Go to SQL Server Agent. b. Then select the job which is giving error and not running successfully. c. Then choose properties and in the General Tab, change the owner to "SA" or any account that has the administrative privileges. The problem will be resolved.

Resetting the Identity Column values.

In case we want to reset the values of the identity column in SQL Server, we can use the following command: DBCC CHECKIDENT (' ', RESEED, 22) The above will now start inserting values from 22+1=23 in the identify column of that table. In case we want to start the value as 1, we should use the command as: DBCC CHECKIDENT (' ', RESEED, 0)

Using GUID or UniqueIdentifiers in SQL Server

In order to differentiate between two rows, we normally use primary keys or identity values which may be same across two tables. In order to overcome this problem we can use a special type named "GUID" . Its a hexadecimal number (Base 16) and the advantage is  that they are unique across all databases and tables.  In SQL Server the same concept is implemented through UNIQUEIDENTIFIER  data type. In order to generate a new value, we use the NEWID() function. For e.g.  a. Creating a table that uses the UNIQUEIDENTIFIER datatype Create table Test ( Empno uniqueidentifier, Ename varchar(20) ) b. Inserting rows in the tables with the use of NEWID() function insert into Test values (newId(),'ABC') insert into Test values (newid(),'XYZ') insert into test values (newid(),'MNO') c. Selecting the rows from the table. Select * from test  Empno                                                                     Ename 6B2CF0E5-DC2E-4E

How to use Common Table Expression in PL/SQL Block

SQL Server provides the option to use Common Table Expressions not only in SQL Queries rather we can use them in a PL/SQL Block. The only thing that we have to take care of is that the immediate line preceding the Common Table Expression must be ended with a semi colon. For e.g. begin declare @vTempVariable varchar(20) Select @vTempVariable=dname from table ; With MyCte(ColumnA, ColumnB) as (      Select ColumnA, ColumB from table1 ) Select *, ColumnA, ColumnB from TableX, Mycte end In the above code, we can see that we have used a semi colon in the SQL Statement that is preceding immediately the Common Table Expression. If we don't use semi colon, it will throw an error.

How to Delete a single row where there is no Primary key in the table and two rows have same values in a single column

In case we have a table that does have any primary key and contains two rows that have exactly same values. For e.g. consider a table named Dept which has two columns: a. Deptno b. Dname And the data in the table is: Deptno Dname 20         Marketing 20         Marketing We can see Deptno column contains two entries with value = 20 and Dname contains same values also. This happened as the record was inserted because, no primary key was present. We cannot delete the row with a delete command. In case we want to do the same we can use Common Table Expressions and Row_Number() function: With MyCTE as  ( Select row_number() over (order by deptno) as 'RowNumber', * from Dept ) Select * from MyCTE The above command will get the following result: RowNumber Deptno Dname 1                 20         Marketing 2                 20         Marketing Now as we have generated RowNumber for a run time column, we can use the sam

How to get Random rows from a Table in SQL Server

Sometimes we require to fetch a number of rows from a table but on a random basis. This can be achieved by using newid() function in SQL Server. For the explanation purpose I have taken the following table and columns to run the query. Table: Mydept Deptno Dname 10 Microsoft 20 Marketing 30 HR 40 SALES 60 LEGAL 80 MANAGEMENT 50 INFOTECH 70 PROMOTION 90 FACULTY Query to get 4 random rows from the MyDept Table Select top(4) deptno, Dname from MyDept order by newId() The result of the query is: deptno Dname 80 MANAGEMENT 30 HR 10 Microsoft 60 LEGAL We can pass on 3, 4, 5 or any number in the top keyword for fetching n number of random rows from the table.