Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 15th, 2005, 04:53 PM
Registered User
 
Join Date: Nov 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Line Break in ntext or varchar records

Is there a way to insert a line break inside a ntext or varchar records. This suppose to be a log record field that each login is a new line in the same record.
I don't want to read the record first and then update it, I would like to perform this in single action.

Thanks.

 
Old November 15th, 2005, 06:11 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Yes, treat it like a normal insert adding a vbCrLf as the line break.
I have a scenario like this inserting into a history table, this tracks who updates records (similar to your log field) this is a Text data type for scaleability. What I do:

'get your existing log/history field
sql = "SELECT history FROM events WHERE id=" & request.form("eId") & ";"
set getHistory = conn.execute(sql)
'append your line break and the new entry
newHistory = getHistory(0) & vbCrLf & newString
'update the field
sql = "UPDATE events SET history = '" & newHistory & "' WHERE id=" & request.form("eId") & ";"
conn.execute(sql)

Wind is your friend
Matt
 
Old November 17th, 2005, 01:49 PM
Registered User
 
Join Date: Nov 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.

I have found a nicer and elegant way to update the record and push it down one line:

    strSQL = "UPDATE table SET record = ISNULL('" & vbcrlf & "' + record,'')
    adoCon.Execute strSQL

Thanks for your help.

 
Old November 17th, 2005, 05:34 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

glad to hear. I must have misunderstood your post, I thought you wanted to append new entries to an existing record inserting a line break in between

BTW, this works?
" & vbcrlf & "' + record,''

I imagine you want to use a & inplace of the +

Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
Line Break in CrossTab timothyc Crystal Reports 0 March 12th, 2008 09:25 PM
result line break. cowbell1 Java Basics 1 October 18th, 2007 05:28 AM
line break Cyber Shiva HTML Code Clinic 1 May 17th, 2007 06:04 AM
line break problem XSLT 1 February 20th, 2006 11:18 AM
break up line crmpicco Javascript How-To 1 June 6th, 2005 06:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.