all groups > sql server programming > april 2006 >
You're in the

sql server programming

group:

Add text to paramaterized query result in SQL Server -- is it possible?


Add text to paramaterized query result in SQL Server -- is it possible? Ranginald
4/16/2006 7:15:07 PM
sql server programming:
Hi,

Question 1:

Say you have a query: SELECT itemID, itemDesc FROM tblItem
that returns the following:

itemID itemDesc
=============
1 Item1
2 Item 2
3 Item 3

Is there a way to add text to this result set. Say for example if you
were using a parameterized query and the goal was to have:
/details.aspx?itemID=X

where "X" is the itemID from the query result?

--------
Question2:

Also--- I know how to do master-detail pages, but in this case I am
using an XML file with an ASP.NET treebinding control.

I have SQL Server view that I convert to .XML to populate the control.
I have a "name" and "id" attribute in the XML file [from the sql server
view], (say name="Item1", ID="1").

I don't want to store the "/details.aspx?ItemID" text in the table for
every item because that defeats the purpose of the relational model.

Is the above question the way to go, or should I be trying to add the
"/details...." text to the XML file's "ID" attribute with XSL and not
messing with the view result set?

Thanks in advance for your help,
Ranginald
RE: Add text to paramaterized query result in SQL Server -- is it poss Grant
4/16/2006 9:08:01 PM
Try this:

create table ta(itemid int identity(1,1),itemdesc nvarchar(20))

insert into ta select 'item1'
union all select 'item2'
union all select 'item3'

select itemid,('/details.aspx?itemID='+cast(itemid as nvarchar(10))) as a
from ta


the results like this:
is it?
-----------------------
1 /details.aspx?itemID=1
2 /details.aspx?itemID=2
3 /details.aspx?itemID=3









[quoted text, click to view]
Re: Add text to paramaterized query result in SQL Server -- is it poss Ranginald
4/17/2006 4:25:14 AM
It works!
I justed used CONVERT instead of CAST for t-sql:

SELECT itemID,'details.aspx?itemID='+CONVERT(nvarchar(10), itemID) AS
Expr1
FROM tblItem

Thanks!!!!!!!!!!
AddThis Social Bookmark Button