Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Insert multiple lines in a single row Expand / Collapse
Author
Message
Posted Monday, January 14, 2013 1:44 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, November 8, 2014 4:17 AM
Points: 206, Visits: 509
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.
Post #1406594
Posted Monday, January 14, 2013 8:13 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 9:10 AM
Points: 13,230, Visits: 12,709
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)
Post #1406755
Posted Tuesday, January 15, 2013 2:00 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, November 8, 2014 4:17 AM
Points: 206, Visits: 509
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?
Post #1407088
Posted Tuesday, January 15, 2013 3:28 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:11 AM
Points: 2,840, Visits: 3,976
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
Post #1407130
Posted Tuesday, January 15, 2013 8:25 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 9:10 AM
Points: 13,230, Visits: 12,709

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)
Post #1407293
Posted Tuesday, January 15, 2013 9:35 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, November 8, 2014 4:17 AM
Points: 206, Visits: 509
@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.
Post #1407580
Posted Tuesday, January 15, 2013 10:12 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:11 AM
Points: 2,840, Visits: 3,976
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
Post #1407588
Posted Wednesday, January 16, 2013 2:29 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, November 8, 2014 4:17 AM
Points: 206, Visits: 509
@Bhuvnesh, I understood your point but right now I have to do in this way that I described. Management Decision.
Post #1407696
Posted Wednesday, January 16, 2013 3:20 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, November 8, 2014 4:17 AM
Points: 206, Visits: 509
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 #1407719
Posted Wednesday, January 16, 2013 3:31 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 1:11 AM
Points: 2,840, Visits: 3,976
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
Post #1407722
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse