I sometimes need to just simply copy a small table to compare it against another run of the same program or some other legitimate reason to copy a table.
This SQL allows creating a new table and populating it with the data from an existing table.
FROM (select * from mytable) G1
I have discovered a new resource that i’ll be checking out. David is a web developer and software engineer. I found this site and will gather much wisdom from it.
I particularly like this quote from the about page.
Reading books will only get you so far — you should spend time with your debugger, experimenting away with whichever technology you need to learn. Always keep an open mind, use tools you wouldn’t usually use, and never give up.
David Walsh Blog
I was looking into ways to get the owner of an Active Directory user. I looked at VBScript and C#.NET. While searching for code and while looking at the objects available in .NET using the object browser I found this MSDN blog entry by Alex Tcherniakhovski.
Extracting object ownership information from Active Directory into SQL
One fact mentioned near the bottom of the blog entry is yet another testimony to keep the Domain Admins group small.
Yet another reason to keep Domain Admins group small.
sADDN = "LDAP://YourContextHere"
Set objUser = GetObject (sADDN)
Set objNtSecurityDescriptor = objUser.Get("ntSecurityDescriptor")
WScript.Echo "Current owner of this item: " & objNtSecurityDescriptor.Owner
Path: C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.DirectoryServices.dll
Path: C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.DirectoryServices.AccountManagement.dll
Name: Active DS Type Library
File Version: 6.1.7600.16385(win7_rtm.090713-1255)
static void Main(string args)
string ADDomain = "yourdomain.com";
string ADUser = "youraduser";
string ADPass = "youradpass";
string ADsAMAccountName = "YOURDOMAIN\\USERNAMEHERE";
using (var pc = new PrincipalContext(ContextType.Domain, ADDomain, ADUser, ADPass))
// get UserPrincipal Object
UserPrincipal inetPerson = UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, ADsAMAccountName);
// Get Directory Entry Object
DirectoryEntry de = inetPerson.GetUnderlyingObject() as DirectoryEntry;
// Get Active Directory Security Object
ActiveDirectorySecurity ads = de.ObjectSecurity;
// Get sid Object
SecurityIdentifier sid = new SecurityIdentifier(ads.GetOwner((typeof(SecurityIdentifier))).Value);
// Translate sid to account
NTAccount account = (NTAccount)sid.Translate(typeof(NTAccount));
// Get owner string
Resources to investigate using Perl
This SQL is helpful when searching for specific strings within SQL code. I have used this code to search in databases too many times to mention. It is especially helpful when looking at a legacy database that I have never looked at before when trying to find things.
WHERE id IN (
WHERE TEXT LIKE '%Outstanding orders confirmed %'
ORDER BY NAME