Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 06, 2012 02:42 AM by Amy Peng - MSFT
Member
11 Points
168 Posts
Nov 05, 2012 05:56 AM|LINK
Hi all
I hava o table in sql with TEXT datatype for column and data is 200+ lines text of document.
Now i want to select 1st line of that column.
How can i achieve that.
Thanks in advance.
Contributor
4646 Points
1172 Posts
Nov 05, 2012 08:22 AM|LINK
Check this link http://stackoverflow.com/questions/1807479/select-only-first-four-lines-from-sql-text-field
3750 Points
886 Posts
Nov 05, 2012 08:26 AM|LINK
select top(1) * from tablename order by id asc
Nov 05, 2012 09:15 AM|LINK
I dont want to select top row
My requirement is like a column contains huge data like full document. in that i want to select first line from that column. and all rows..
327 Points
157 Posts
Nov 05, 2012 09:33 AM|LINK
Hi,
I don't know it's helpful to you or not but try this
declare @Name as nvarchar(200) select top 1 @Name = YourDetails from tblemployeemaster print @Name
Here YourDetail is your nvarchar(max) field.
You take it in Variable named @Name which has length 200 character.
So you'll get 200 character only from nvarchar text.
Hope it's helpful to you.
Nov 05, 2012 09:47 AM|LINK
Hi I an so thankful for ur reply, I can achieve your trik by SubString(Ti, 1, 25) also.
But all I need is
SELECT id, name, [Document] FROM Book_table
This works fine but the [
Document
Here i need to select first line of that....
Star
14460 Points
2402 Posts
Nov 05, 2012 10:07 AM|LINK
Use Text Function to get result.
I think TEXTPTR function will work for you.
Check msdn help
http://msdn.microsoft.com/en-us/library/ms176068.aspx
10122 Points
958 Posts
Microsoft
Nov 06, 2012 02:42 AM|LINK
Hi sush_indus,
The following thread is also about select the first line in the text field, please try to refer to: http://stackoverflow.com/questions/9229060/select-just-first-line-of-chars-upto-cr-lf-from-a-text-field .
Regards, Amy Peng
sush_indus
Member
11 Points
168 Posts
Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 05, 2012 05:56 AM|LINK
Hi all
I hava o table in sql with TEXT datatype for column and data is 200+ lines text of document.
Now i want to select 1st line of that column.
How can i achieve that.
Thanks in advance.
chandu123
Contributor
4646 Points
1172 Posts
Re: Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 05, 2012 08:22 AM|LINK
Check this link http://stackoverflow.com/questions/1807479/select-only-first-four-lines-from-sql-text-field
Chandrasekhar (MCTS) .NET framework 3.5, ASP.NET Applications
If my ANSWER helps you in solving your problem MARK IT AS ANSWER
kaushikmahet...
Contributor
3750 Points
886 Posts
Re: Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 05, 2012 08:26 AM|LINK
select top(1) * from tablename order by id asc
Remember to click Mark as Answer on the post that helps to others.
sush_indus
Member
11 Points
168 Posts
Re: Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 05, 2012 09:15 AM|LINK
I dont want to select top row
My requirement is like a column contains huge data like full document. in that i want to select first line from that column. and all rows..
juhi_it
Member
327 Points
157 Posts
Re: Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 05, 2012 09:33 AM|LINK
Hi,
I don't know it's helpful to you or not but try this
declare @Name as nvarchar(200)
select top 1 @Name = YourDetails from tblemployeemaster
print @Name
Here YourDetail is your nvarchar(max) field.
You take it in Variable named @Name which has length 200 character.
So you'll get 200 character only from nvarchar text.
Hope it's helpful to you.
Juhi Paunikar
Software Developer
sush_indus
Member
11 Points
168 Posts
Re: Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 05, 2012 09:47 AM|LINK
Hi I an so thankful for ur reply, I can achieve your trik by SubString(Ti, 1, 25) also.
But all I need is
This works fine but the [
Document] Type in SQL Server is text and is very long (think a magazine article).Here i need to select first line of that....
yrb.yogi
Star
14460 Points
2402 Posts
Re: Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 05, 2012 10:07 AM|LINK
Use Text Function to get result.
I think TEXTPTR function will work for you.
Check msdn help
http://msdn.microsoft.com/en-us/library/ms176068.aspx
.Net All About
Amy Peng - M...
Star
10122 Points
958 Posts
Microsoft
Re: Select only first three lines from Sql text field (Format and select in SQL 2008)
Nov 06, 2012 02:42 AM|LINK
Hi sush_indus,
The following thread is also about select the first line in the text field, please try to refer to: http://stackoverflow.com/questions/9229060/select-just-first-line-of-chars-upto-cr-lf-from-a-text-field .
Regards,
Amy Peng
Feedback to us
Develop and promote your apps in Windows Store