Yorkshire Divers

Ocean Explorers
Go Back   YD Dive Forums & Scuba Community > Non-Diving Related Forums > Non Diving Posts
User Name
Password

Welcome to the YD Scuba forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Non Diving Posts: Discuss SQL Assistance in the Non-Diving Related Forums forums: Hi can someone help me with the following I have two fields in a table that need to be concatenated ...

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-05-08, 02:52 PM
Garf's Avatar
Garf Garf is offline
Chimp 2
 

Join Date: Aug 2003
Location: West Sussex
Posts: 5,801
Garf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fish
SQL Assistance

Hi

can someone help me with the following

I have two fields in a table that need to be concatenated into a third field in the following format

Field1, ' ','-',' ', Field2

Here's the fun bit. all three fields are ntext.

Oh this is MS SQL2000 not 2005 so dont even get me started on varchar(max)

I know its something to do with updatetext but I've nevr used it.
__________________
Garf
Postatem obscuri lateris nescitis.
www.teamfoxturd.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-05-08, 03:18 PM
Lazlo's Avatar
Lazlo Lazlo is offline
Bored
 
Join Date: Jul 2005
Location: York
Posts: 2,191
Lazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold water
Can't you just do a normal INSERT using the + operator to concatenate?
__________________
Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-05-08, 03:21 PM
Lazlo's Avatar
Lazlo Lazlo is offline
Bored
 
Join Date: Jul 2005
Location: York
Posts: 2,191
Lazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold water
Sorry, UPDATE obviously, not INSERT (duh)
__________________
Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-05-08, 03:58 PM
Garf's Avatar
Garf Garf is offline
Chimp 2
 

Join Date: Aug 2003
Location: West Sussex
Posts: 5,801
Garf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fish
Quote:
Originally Posted by Lazlo
Sorry, UPDATE obviously, not INSERT (duh)
NO, UPDATE DOESN'T WORK FOR NTEXT FIELDS


whoops, sorry

edit: however, moving the table temporarily to SQL2005 and then doing this works...

UPDATE MIGRATION_COMMUNICATION SET COMM_NOTE=RTRIM(COALESCE((CAST(DOCDESC AS VARCHAR(MAX))),'')) + ' '+'-'+' ' +
RTRIM(COALESCE((CAST(MEMO AS VARCHAR(MAX))),'')) FROM MIGRATION_COMMUNICATION
__________________
Garf
Postatem obscuri lateris nescitis.
www.teamfoxturd.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-05-08, 04:07 PM
Lazlo's Avatar
Lazlo Lazlo is offline
Bored
 
Join Date: Jul 2005
Location: York
Posts: 2,191
Lazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold water
Try WRITETEXT instead of UPDATE, something like this. I'm guessing on the exact syntax here cos I don't have a SQL2000 database to play with.

WRITETEXT MIGRATION_COMMUNICATION.COMM_NOTE
(SELECT RTRIM(DOCDESC) + ' '+'-'+' ' + RTRIM(MEMO) FROM MIGRATION_COMMUNICATION)
__________________
Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-05-08, 04:07 PM
wilbo's Avatar
wilbo wilbo is offline
Chimp 4
 

Join Date: Jul 2004
Location: Swindon (the hairy sphincter of the world)
Posts: 5,284
wilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the waterwilbo is never out of the water
Quote:
Originally Posted by Garf
edit: however, moving the table temporarily to SQL2005 and then doing this works...
Pfft. stroke.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-05-08, 04:11 PM
Garf's Avatar
Garf Garf is offline
Chimp 2
 

Join Date: Aug 2003
Location: West Sussex
Posts: 5,801
Garf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fishGarf communes with fish
Quote:
Originally Posted by wilbo
Pfft. stroke.

actually my solution is a bit strokey tbh. Using SQL2005 kit to make up for a lack of sql 2000 knowledge.
__________________
Garf
Postatem obscuri lateris nescitis.
www.teamfoxturd.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-05-08, 04:14 PM
Lazlo's Avatar
Lazlo Lazlo is offline
Bored
 
Join Date: Jul 2005
Location: York
Posts: 2,191
Lazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold waterLazlo is a scuba diver - cold water
Update to the above. Looks like you need a TEXTPTR as part of the syntax. So the above gets changed to:

DECLARE @ptrval varbinary(16)

SELECT @ptrval = TEXTPTR(MIGRATION_COMMUNICATION.COMM_NOTE)

WRITETEXT MIGRATION_COMMUNICATION.COMM_NOTE @ptrval
(SELECT RTRIM(DOCDESC) + ' '+'-'+' ' + RTRIM(MEMO) FROM MIGRATION_COMMUNICATION)
__________________
Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Sponsored Links

Yorkshire Divers - RSS Feed
All times are GMT +1. The time now is 10:57 PM.
Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0 RC6
Trademark and all rights reserved : © YD.com Ltd (2006)
YD.com Ltd (Registered in England - 05886696)
Other sites : Golf Clubs | New Premiership Football Kits | MP3 Portable Players | MP3 Players For Sale | Replica Football Kits

Forums Directory