July 20, 2000

Precedence of the * and []Operators

The array subscript operator, [], has a higher precedence than the pointer dereference operator, *. Therefore, the following snippet declares an array of 10 pointers to char, not a pointer to an array of 10 characters: char * p2 [10]; You can read the declaration as follows: because the array

Creating and Executing a Variable as a Query

Question: How do I create a stored procedure that will construct and execute a query from its parameters? At the heart I’d imagine something like this, for simplicity’s sake: declare @foobar varchar(255)select @foobar = “select * from aTable”exec @foobar I know removing the ‘exec’ command doesn’t launch the query. Answer:

Date Time Fields

Question: I have a database with a DateTime field of the following structure 1974-01-18T00:00:00′. How do I query it so that I can extract the dates with a particular day and month but any year? Answer: The datepart function in SQL will retrieve a portion of the date: create table

Large Text Fields

Question: How do I create a text field of greater than 8,000 characters (in v7.0)? I attempted to use the “text” data type, but my code returned an error saying the maximum size was 8,000. Here’s the code: CREATE TABLE X ( X_ID int IDENTITY(1,1), X_DESC text (60000) NOT NULL)GO

Storing RTF Text

Question: I’m trying to store text that’s in an RTF format using the TextRTF property of VB’s RichTextBox control. What type of field do I have to use in my table? Answer: The data in a rich text box actually is still text, but it contains tags for all the

Rolling 12-Month Totals

Question: I have two similar tables with monthly data: one holds current year data and the other holds prior year data. How do I combine them to create a rolling 12-month view or table? Answer: If I understand your question correctly, you can use UNION to combine the results of

Converting Number to Date

Question: How do I convert a number that represents a date into a date field? The number’s format is CCYYMMDD. Answer: Fortunately, the format of your numeric value doesn’t need any modifications to save it to a date value. Assuming your numeric value is 20000710 for July 10, 2000, just

CopyURLToFile – Download a file from the Internet via FTP or HTTP

Const INTERNET_OPEN_TYPE_PRECONFIG = 0Const INTERNET_FLAG_EXISTING_CONNECT = &H20000000Private Declare Function InternetOpen Lib “wininet.dll” Alias “InternetOpenA” _ (ByVal lpszAgent As String, ByVal dwAccessType As Long, _ ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, _ ByVal dwFlags As Long) As LongPrivate Declare Function InternetOpenUrl Lib “wininet.dll” Alias _ “InternetOpenUrlA” (ByVal hInternetSession As

Auto Start Full Text Index

Question: Can I auto start full text index? Answer: Although Enterprise Manager doesn’t provide the option, you can set this service to start automatically by using the services icon in Control Panel. Click the startup button after highlighting the “Microsoft Search” service and choose the “automatic” option.

No more posts to show