Monday, August 31, 2020

How to create a comma separated list with group by in SQL SERVER

Say you have a table t with following values and you need comma separated name group by ID

ID    Name

1 A

2 B

3 C

4 D

4 E


SELECT ID, STRING_AGG(Name, ', ') AS Names

FROM (

select ID, Name from t)s

GROUP BY ID


This will give the following result:

ID     Names

1 A

2 B

3 C

4 D, E


Monday, April 28, 2014

How to move almost any android app to SD card


One major problem many android users face is: running out of internal memory.
I was having the same problem and almost uninstalled every app. But there were some apps which were taking lot of memory but had no option to be moved to SD card.

After some googling, I found the solution.

Step 1. Download sdk tools from this link
            http://www.mediafire.com/download/2j8oai9z88fain9/sdk-tools.zip
            Unzip it to a folder, let's say C:\sdk

Step 2. Enable USB debugging on your phone from Settings -> Developer options ->USB debugging
            It gives a warning, just ignore that.

Step 3. Connect the phone to PC in charging mode.

Step 4. Open a command promt in administrator mode.Navigate to C:\sdk (or any other folder where you                 extracted the sdk).

Step 5. Type adb devices and press enter.
             Type adb shell and press enter.

Step 6. Type pm set-install-location 2

Step 7. Type exit.

Now all the stubborn apps which were not moving to SD card can be moved.

Enjoy your freed up memory.

Tuesday, June 11, 2013

Find which tables are referring to a table

Sometimes there is a situation when we want to know which tables are referring to a particular table.
Most common place where we need this information is, when you don't delete the record physically but just flag it for deletion.

Here is the query to find out:

select a.name as ConstraintName, f.name as FromTable
from sysobjects a, sysobjects f, sysobjects t, sysforeignkeys b
where a.id=b.constid and f.id=b.fkeyid and t.id=b.rkeyid and t.name= 'TableName'


Friday, February 1, 2013

How to delete Windows.old folder

If you have upgraded your OS to windows7 or windows8 and opted for not formatting the system partition, it will move the system files and installed program files to a folder named Windows.old
And it won't let you delete this folder. So you are left with a folder which is hardly of any use taking up a lot of hard disk space.

Here is how you can delete it:
1. Open "My computer" and right click the system drive (C: in most cases) and select Disk cleanup
 

2. Click on "Clean up system files". It would present another similar dialog.
3. From the list, select "Previous Windows installation" and click ok.

And it deletes the folder.
You are welcome.

Turning off Attach Security Warning popup in VS

Every time you run your application from VS, it asks to attach the process, which is very annoying.
To turn off that dialog, follow these steps:

1. Goto registry (regedit.exe)
2. Select HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Debugger
3. It has a DWORD value "DisableAttachSecurityWarning", change it to 1 (default is 0).

There is a catch. If VS is already running, it would ignore this change in the current session and while u close VS, it resets this registry entry.
So, change this registry key when VS is not running.
You are welcome.
 

You do not have suffucient privileges to complete this installation

While installing some softwares in either Win7 or Win8, this error is quite familiar.
After searching a lot for the solution, here is what I found.

1. Run command prompt as Administrator. (Goto %Windir%\System32 locate cmd.exe, right click and select "Run as administrator")
2. Type the following command "msiexec /a yoursetupfile.msi"

Replace yoursetupfile.msi with you actual setup file name.

Thursday, January 31, 2013

How to always run as Administrator in Windows 8

After upgrading the OS to Windows 8, the first problem that I encountered was, I need to run many of the apps as Administrator or else they won't run as expected. And that includes even VS 2008.
Imagine you need to every time right click and select "Run as Administrator".

I found a solution to this and thought of sharing this with others too.
First thing you need to do is, turn off UAC.
After you have turned it off, follow these steps:
1. Go to the executable, right click on it and select "Troubleshoot compatibility"
2. Select "Troubleshoot program"
3. Choose "The program requires additional permissions".
5. Click "Test the program" (required), save and close the wizard.