Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Insert multiple lines in a single row


Insert multiple lines in a single row

Author
Message
shohelr2003
shohelr2003
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 610
Dear,
I want to insert multiple lines in a single row in SQL Server 2008 R2. I have tried. But it's not working. A table has only one column and it contains information like following.
Name: XYZ
Cell:1325646
Blood: B+


How is it possible? Please help me.
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16539 Visits: 16992
shohelr2003 (1/14/2013)
Dear,
I want to insert multiple lines in a single row in SQL Server 2008 R2. I have tried. But it's not working. A table has only one column and it contains information like following.
Name: XYZ
Cell:1325646
Blood: B+


How is it possible? Please help me.


Are you sure it "isn't working"? SSMS will display it in a single line if you have the output showing in a grid. If you change the output to text it will display multiple lines.


create table #MultiRow
(
   SomeValue varchar(1000)
)

insert #MultiRow
select 'Name: XYZ
Cell:1325646
Blood: B+'

select * from #MultiRow

drop table #MultiRow



Ctrl+T = Results to Text
Ctrl+D = Results to Grid

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
shohelr2003
shohelr2003
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 610
Thank you, Sir. Your code works.

Actually I wanna convey SMS from my database through mobile operator. That's why I want to insert data in my convenient format. If I use char(13) + char(10), it will work too, won't it?

Another query is when sms will be sent, do the format remain same or will be changed?
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2924 Visits: 4076
shohelr2003 (1/15/2013)
Thank you, Sir. Your code works.

Actually I wanna convey SMS from my database through mobile operator. That's why I want to insert data in my convenient format. If I use char(13) + char(10), it will work too, won't it?

Another query is when sms will be sent, do the format remain same or will be changed?
can you post the table defintion from which above data will be picked uo as SMS content.

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16539 Visits: 16992

Actually I wanna convey SMS from my database through mobile operator. That's why I want to insert data in my convenient format. If I use char(13) + char(10), it will work too, won't it?


Did you try it? Yes it should work.


Another query is when sms will be sent, do the format remain same or will be changed?


That is up to the provider. I would guess that most of them will not reformat the input but I can't tell you what any given provider might do.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
shohelr2003
shohelr2003
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 610
@Bhuvnesh,
Actually it is a distributed query. I wrote an AFTER TRIGGER that will fetch information from six tables that will be SMS content and insert into a remote database's VIEW. In addition to, I formatted the SMS body as business requirements from the database information.


@Sean Lange,
By googling I came to know char(13)+char(10). I have tried it and it worked. We talked to mobile operator and they told me they are blind about the sms. They will just convey the sms.
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2924 Visits: 4076
shohelr2003 (1/15/2013)
@Bhuvnesh,
Actually it is a distributed query. I wrote an AFTER TRIGGER that will fetch information from six tables that will be SMS content and insert into a remote database's VIEW. In addition to, I formatted the SMS body as business requirements from the database information.
then you would be experiencing performance issues soon .

your AFTER trigger approach(Working on 6 table) will be synchronous approach to play with data (plus remote database migration too), i will say to manage the load , you need to go with asynchronous approach like Service Broker. sooner or later you wil find it beneficial .

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
shohelr2003
shohelr2003
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 610
@Bhuvnesh, I understood your point but right now I have to do in this way that I described. Management Decision.
shohelr2003
shohelr2003
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 610
If I execute an insert query into linked server, it works. But when I use trigger to execute an insert query into linked server, it fails and generates the following error message.

"The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "Server2" was unable to begin a distributed transaction."
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2924 Visits: 4076
shohelr2003 (1/16/2013)
If I execute an insert query into linked server, it works. But when I use trigger to execute an insert query into linked server, it fails and generates the following error message.

"The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "Server2" was unable to begin a distributed transaction."
post the trigger code

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search