Database
PREVIOUS
NEXT
Delete an LDAP object using ldapmodify
Using ldpamodify to manipulate a directory server from the command line enables rapid changes (quicker than loading a GUI in some cases) and allows commands to be scripted for automation.Any recipe with the word delete in the title must be used with caution. Please backup your directory server before doing this.
To delete an object, you must know it's distinguished name (dn). Consider the following object to be deleted:
uid:qmchenry, ou=people, dc=tech-recipes, dc=com
ldpamodify takes commands from the standard input. These commands are in a format called LDIF (lightweight directory interchange format). Once you start ldapmodify and authenticate, it will expect LDIF input without prompting you. The LDIF commands to delete the above object is:
ldapmodify -D "cn=Directory Manager"
Bind password: <enter your Directory Manager password>
dn: uid:qmchenry, ou=people, dc=tech-recipes, dc=com
changetype: delete
After the LDIF code, there are two blank line... Read More
Mimic The MySQL LIMIT Feature in Microsoft SQL Server
MySQL includes a nifty feature that lets you select only rows 1-10, 11-20, or any set you want. Microsoft SQL Server does not include this feature. This recipe will show you how to mimic the same feature easily without stored procedures.Microsoft's T-SQL includes the TOP syntax, which allows you to select only the top x number of records from your SQL query. This is very useful for testing purposes or selecting a single record, but less useful for production applications where you might want to do some sort of paging.
What we will do is use the TOP feature in reverse. We will select the top 20 records in a particular order, and then reverse the order and select the top 10 of those.
SELECT TOP 10 *
FROM (SELECT TOP 20 * FROM Orders ORDER BY OrderDate) as T
ORDER BY OrderDate DESC
The subselect SQL statement will return the top 20 orders by date. Then we will select the top 10 of those and reverse the sort order back.
If we want to select orders 20-30 in the list, we would simply... Read More
SQL2000 - Find Database Language
How to find the system language of a server running SQL2000 using a SQL statement.I recently had a client who was having problem with date format in SQL2000 after moving from a UK based server to a German one. In order to check that the database was set to the correct language locale, run the following code in Query Analyser and the database language will be returned:
select @@langid, @@language
select dateformat from master..syslanguages where langid = @@langid... Read More
SQL 2000 - Find version and service pack info
Run the following code in SQL Server 2000 Query Analyzer to return the Version and Service pack - useful if you're having problems on a server and don't know if you're running the latest patches or not.
SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY
('productlevel'), SERVERPROPERTY ('edition')... Read More