Just a short SQL script which will allow you to find mutiple rows with same values in a table. Since its a very straightforward query, it needs no further explanation :)

  1. select [column_name]
  2. from [tablename]
  3. group by [column_name]
  4. having count(*) > 1
  5. -- � OR
  7. Select * from [TableName] where [ColumnName] IN (
  8. select [ColumnName] from (
  9. select count([ColumnName]) as N, [ColumnName] from [TableName]
  10. -- Where Clause If needed
  11. group by [ColumnName]
  12. )a
  13. where N > 1
  14. )

There is a similar article which describes more techniques to follow for managing duplicate rows from a table .


Sphere: Related Content

Tagged with:  

I sure lot of people might want to use the script where they would want to loop over multiple databases sitting on a Single server. In my case, I had to check for a Login Record in all the databases since the person left the company and we wanted to disable his/her access. SO I wrote simple CURSOR script in MSSQL 2000. Hope this help to someone.

  1. USE master
  3. DECLARE db_names CURSOR FOR
  4. SELECT name from sysdatabases
  5. -- Where Clause, Enable if you want to filter out some databases.
  6. --where name like 'databaseIwantName_%' and name not like 'databaseIdontwantName'
  8. DECLARE @db_name varchar(100)
  9. DECLARE @QueryString NVARCHAR(500)
  10. DECLARE @UpdateString NVARCHAR(500)
  12. OPEN db_names
  13. FETCH NEXT FROM db_names INTO
  14. @db_name
  16. BEGIN
  17. --PRINT @db_nam
  18. --In My case I used tbl_logins to do multiple select .
  19. SET @QueryString = 'Select * from ' + @db_name + '..logins where login like ''%loginname%'' '
  20. EXEC sp_executesql @QueryString
  22. IF @@RowCount > 0
  23. BEGIN
  24. -- This gives the database name if there are any record found with the select state ran above
  25. PRINT @db_name
  26. END
  28. --Similarly you can also have any Insert/Update Query IN a Loop.See example below
  29. --In My case I used tbl_logins to do multiple Update At Once.
  30. --SET @UpdateString = 'update ' + @db_name + '..tbllogins set password = ''account_blocked_out'', security_level = 0, approved = 0 where login like ''%loginname%'''
  31. --PRINT @UpdateString
  32. --EXEC sp_executesql @UpdateString
  34. FETCH NEXT FROM db_names INTO
  35. @db_name
  36. END
  38. CLOSE db_names
  39. DEALLOCATE db_names

This is something written quick. Here is the Code for your Download. I am sure you can tune it better and if you do, please let me know . I would love to see your Ideas.


Sphere: Related Content

Troubleshooting Random null null Error in Coldfusion MX

On September 14, 2007, in Technical, by Rahmansaher

I have been looking so much for this error in Coldfusion MX but could not find any solution to my problem. null null is a very vague exception error which gets thrown once in a while. Below are the steps I did to troubleshoot and one of them did the solved the problem.

1) Apply this hot fix from Adobe.

2) Increase the JVM Heap Size. (I increased it from 512 to 800)

3) Make sure your SELECT query does not pass any corrupt data. It might also be the very cause to throw the exception error.Turning off query caching signifigantly increased the number of errors, so it seems to be something in the JDBC drivers.

4) Check to see if you have methods that accept parameters passed by reference(like getimagesize()) . Make sure you use right script language for example getimagesize uses VBSCRIPT not JSCRIPT. ( For me this was the case. I removed this method and it stopped the error completely).

Sphere: Related Content

Tagged with:  

Some Windows Run Commands

On January 8, 2007, in Technical, by Rahmansaher

I thought it would be beneficial to my blog readers to show some of the Windows RUN Commands which will take you directly to the place you want to go !

To Access.. – Run Command
Accessibility Controls – access.cpl
Add Hardware Wizard – hdwwiz.cpl
Add/Remove Programs – appwiz.cpl
Administrative Tools – control admintools
Automatic Updates – wuaucpl.cpl
Bluetooth Transfer Wizard – fsquirt
Calculator – calc
Certificate Manager – certmgr.msc
Character Map – charmap
Check Disk Utility – chkdsk
Clipboard Viewer – clipbrd
Command Prompt – cmd
Component Services – dcomcnfg
Computer Management – compmgmt.msc
Date and Time Properties – timedate.cpl
DDE Shares – ddeshare
Device Manager – devmgmt.msc
Direct X Control Panel (If Installed)* – directx.cpl
Direct X Troubleshooter – dxdiag
Disk Cleanup Utility – cleanmgr
Disk Defragment – dfrg.msc
Disk Management – diskmgmt.msc
Disk Partition Manager – diskpart
Display Properties – control desktop
Display Properties – desk.cpl
Display Properties (w/Appearance Tab Preselected) – control color
Dr. Watson System Troubleshooting Utility – drwtsn32
Driver Verifier Utility – verifier
Event Viewer – eventvwr.msc
File Signature Verification Tool – sigverif
Findfast – findfast.cpl
Folders Properties – control folders
Fonts – control fonts
Fonts Folder – fonts
Free Cell Card Game – freecell
Game Controllers – joy.cpl
Group Policy Editor (XP Prof) – gpedit.msc
Hearts Card Game – mshearts
Iexpress Wizard – iexpress
Indexing Service – ciadv.msc
Internet Properties – inetcpl.cpl
IP Configuration (Display Connection Configuration) – ipconfig /all
IP Configuration (Display DNS Cache Contents) – ipconfig /displaydns
IP Configuration (Delete DNS Cache Contents) – ipconfig /flushdns
IP Configuration (Release All Connections) – ipconfig /release
IP Configuration (Renew All Connections) – ipconfig /renew
IP Configuration (Refreshes DHCP & Re – Registers DNS) – ipconfig /registerdns
IP Configuration (Display DHCP Class ID) – ipconfig /showclassid
IP Configuration (Modifies DHCP Class ID) – ipconfig /setclassid
Java Control Panel (If Installed) – jpicpl32.cpl
Java Control Panel (If Installed) – javaws
Keyboard Properties – control keyboard
Local Security Settings – secpol.msc
Local Users and Groups – lusrmgr.msc
Logs You Out Of Windows – logoff
Microsoft Chat – winchat
Minesweeper Game – winmine
Mouse Properties – control mouse
Mouse Properties – main.cpl
Network Connections – control netconnections
Network Connections – ncpa.cpl
Network Setup Wizard – netsetup.cpl
Notepad – notepad
Nview Desktop Manager (If Installed) – nvtuicpl.cpl
Object Packager – packager
ODBC Data Source Administrator – odbccp32.cpl
On Screen Keyboard – osk
Opens AC3 Filter (If Installed) – ac3filter.cpl
Password Properties – password.cpl
Performance Monitor – perfmon.msc
Performance Monitor – perfmon
Phone and Modem Options – telephon.cpl
Power Configuration – powercfg.cpl
Printers and Faxes – control printers
Printers Folder – printers
Private Character Editor – eudcedit
Quicktime (If Installed) – QuickTime.cpl
Regional Settings – intl.cpl
Registry Editor – regedit
Registry Editor – regedit32
Remote Desktop – mstsc
Removable Storage – ntmsmgr.msc
Removable Storage Operator Requests – ntmsoprq.msc
Resultant Set of Policy (XP Prof) – rsop.msc
Scanners and Cameras – sticpl.cpl
Scheduled Tasks – control schedtasks
Security Center – wscui.cpl
Services – services.msc
Shared Folders – fsmgmt.msc
Shuts Down Windows – shutdown
Sounds and Audio – mmsys.cpl
Spider Solitare Card Game – spider
SQL Client Configuration – cliconfg
System Configuration Editor – sysedit
System Configuration Utility – msconfig
System File Checker Utility (Scan Immediately) – sfc /scannow
System File Checker Utility (Scan Once At Next Boot) – sfc /scanonce
System File Checker Utility (Scan On Every Boot) – sfc /scanboot
System File Checker Utility (Return to Default Setting) – sfc /revert
System File Checker Utility (Purge File Cache) – sfc /purgecache
System File Checker Utility (Set Cache Size to size x) – sfc /cachesize=x
System Properties – sysdm.cpl
Task Manager – taskmgr
Telnet Client – telnet
User Account Management – nusrmgr.cpl
Utility Manager – utilman
Windows Firewall – firewall.cpl
Windows Magnifier – magnify
Windows Management Infrastructure – wmimgmt.msc
Windows System Security Tool – syskey
Windows Update Launches – wupdmgr
Windows XP Tour Wizard – tourstart
Wordpad – write

Sphere: Related Content

Tagged with: