Solved

SQL - As [Text()] Syntax?

Posted on 2014-02-21
7
186 Views
Last Modified: 2014-02-24
I'm working on a project using SQL Report Builder 3.0 and using Stored Procedures. The following address displays having line-breaks as it should. I don't notice any difference including 'as [text()]' or not.

Okay, what does 'as [text()] do?

SUBSTRING
((
SELECT companyName + char(10) + address1 + char(10) + address2 as [text()]
FROM Addresses
For XML PATH(''), elements),1,200) as [Mailing_Address]
0
Comment
Question by:WorknHardr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 117 total points
ID: 39878445
It names the result column. No more, no less.

Bye, Olaf.
0
 

Author Comment

by:WorknHardr
ID: 39878455
Can you explain more...
0
 
LVL 34

Assisted Solution

by:Brian Crowe
Brian Crowe earned 117 total points
ID: 39878684
It creates an alias for the column.  In this case your column will be called "text()".  The brackets around it are delimiters that allow you to include characters that would otherwise cause a syntax error like a space or parentheses.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:WorknHardr
ID: 39878687
I thought it had something to do with SQL Report Builder 3.0... Just a guess...
0
 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 116 total points
ID: 39881208
It is just a column alias. You can execute the query in SSMS and observe the column alias as text().
0
 

Author Closing Comment

by:WorknHardr
ID: 39883178
Cool, thx...
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39884832
Naming/Aliasing a column that way may be part of trickery with coe evaluating something, but on the SQL level it simply gives the column name for the expression companyName + char(10) + address1 + char(10) + address2. Without it, the field would be named expr_1, for example, or whatever automatic name would be given.

It's not even specifying the field type TEXT, tha would need a CONVERT or CAST.

Bye, Olaf.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question