Solved

SQL - As [Text()] Syntax?

Posted on 2014-02-21
7
185 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

734 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