Help with SQL

Results 1 to 2 of 2

Thread: Help with SQL

  1. #1
    Join Date
    Dec 1969

    Default Help with SQL

    Hello,<BR><BR> I need to insert a large amount of data into a SQL Server 6.5 table. Similar to how this message board does. I noticed that this forum uses MS Access and this field is a "MEMO" type. I am using SQL and it has no "MEMO" type. So my question is how can I insert this into my SQL table. What is the SQL equivalant of a memo field. I tried "text" and "binary" But both give errors. PLEASE HELP.

  2. #2
    Ben Jones Guest

    Default RE: Help with SQL

    The "text" datatype can store hundreds of megabytes worth of data. If you received errors then the problem was likely one of the following:<BR><BR>1. you were missing &#039[text here]&#039 (single quotes) around your string inserts;<BR>2. you didn&#039t parse the string, converting &#039 to &#039&#039;<BR>3. you were trying to insert a value in the primary key field;<BR>4. you were trying to insert a null value into a numeric field;<BR>5. you were mismatching your datatypes in the insert statement, or your field order is different between the names and values;<BR>6. your field names were wrong;<BR>7. your insert statement was improperly structured.<BR><BR>Here is an example ...<BR><BR>&#060;%<BR><BR>first_name = "Ben"<BR>last_name = "Jones"<BR>favourite_number = 99<BR>biography = "miscellaneous random text that would almost certainly exceed the 255 character field limit in SQL Server 6.5 for varchar and char datatypes, and may exceed 16, 32, 48K, etc. for particularly large entries."<BR><BR><BR>&#039 parse string fields<BR>first_name = replace(first_name, "&#039", "&#039&#039")<BR>last_name = replace(last_name, "&#039", "&#039&#039")<BR>biography = replace(biography, "&#039", "&#039&#039")<BR><BR><BR>&#039 create dedicated fields to non-essential numeric fields which could crash an insert if they are NULL<BR>sSQLfields = ""<BR>sSQLvalues = ""<BR><BR>if len(favourite_number) > 0 then<BR> sSQLfields = ", favourite_number"<BR> sSQLvaluse = ", " & favourite_number<BR>end if<BR><BR><BR>&#039 open dbase connection<BR>sSQL = "INSERT INTO table_name (first_name, last_name, biography" & sSQLfields) VALUES (&#039" & first_name & "&#039, &#039" & last_name & "&#039, &#039" & biography & "&#039" & sSQLvalues & ")"<BR>set RS = Conn.Execute(sSQL)<BR><BR>&#039 close dbase and destroy all objects<BR><BR>&#037;&#062;<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts