Add "/" to the field in Table A to convert the string and add "/" to the field in Table B to insert data into Table C.

Source: Internet
Author: User

For example:
Table A Table B Table C
SN1 contect1 Sn2 conect2 help
1. Hello. 1. Yes. Hello./very good./General./Yes./indeed./Yes./hello.
2. Good. + 2. How are you doing?
3 General situation
4. Yes.
5 is really good

That is to say, the content of the conect field in a and B is combined into the help field in Table C and displayed in text form.

 

-- Xiaoliang:

Declare @ Re varchar (8000 );
Set @ Re = '';

Select
@ Re = @ Re + contect1 + '/'
From DNT

Select
@ Re = @ Re + conect2 + '/'
From TBB

Set @ Re = left (@ Re, Len (@ Re)-1 );

Select @ Re

 

-- Old d

Create Table A (SN1 int, contect1 varchar (10 ))
Create Table B (Sn2 int, contect2 varchar (10 ))
Insert into a values (1, '')
Insert into a values (2, 'good') insert into a values (3, 'General situation ')
Insert into a values (4, 'Yes ')
Insert into a values (5, 'Really good ')
Insert into B values (1, 'true ')
Insert into B values (2, 'Hello ')
Go

Declare @ output1 varchar (8000)
Select @ output1 = coalesce (@ output1 + '/', '') + contect1 from
Declare @ output2 varchar (8000)
Select @ output2 = coalesce (@ output2 + '/', '') + contect2 from B

Print @ output1 + '/' + @ output2

Drop Table A, B

/*
Hello/very good/General/yes/indeed good/Yes/Hello
*/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.