Solved

SQL - As [Text()] Syntax?

Posted on 2014-02-21
7
184 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL eating up memory? 16 42
how to make geography query faster?  SQL 7 46
Applying Roles in Common Scenarios 3 22
Convert time stamp to date 2 58
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.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

730 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