devxlogo

Tip Bank

T-SQL Data Conversion

Question: I want to convert a signed integer into a 16-bit binary as part of a SELECT statement. For example: select myint, howeveritsdone as Binaryfrom mytablemyint Binary—- —————–137 1111111101110111-100 1111111110011100

Truncating the Last Five Characters in a Field

Question: How do I truncate the last five characters in a field? (The string length varies from row to row.) Answer: Try something along these lines: select left(myfield, datalength(myfield)-5)

Using XML Within VBA

Question: Does XML work with VBA (Visual Basic for Applications)? I’m looking for a quick and easy way to store variable information that will be static once it has been

Creating a Crosstab

Question: How can I create a crosstab in SQL Server 7.0? I’m used to Microsoft Access, where I can use columnheading and rowheading. Does this work in SQL? Answer: This

Extracting Dates

Question: How do I extract dates from SQL where the date type is a datetimestamp? I have the following SQL statement: select * from Patient where PatientDOB = “03/01/58” It

Insert Trigger on Parent Table

Question: I have two tables and both tables have a one-to-many relationship. I want to add a new single record in the first “transheader” table (key is autonumber) and get

Modify XML Using DCOM From the Cache

Question: How can I modify and update XML docs that are stored in the cache using a DCOM model (client side)? Answer: Given that caching is an IIS (Internet Information

SQL Using Like to Search for

Question: I have created a database of journal articles and want to offer users the ability to search the Author field for the surnames of authors. Most of the articles