Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 concatenate on an insert statement

Author  Topic 

sbuser
Starting Member

6 Posts

Posted - 2007-11-12 : 10:41:39
I am running an insert in a stored procedure, but need tio concatenate on of the fields. How do I do that? Below is an example:

INSERT sam.dbo.product
( productName,
ProdDesc,
TransDateBegin,
TransDateEnd
)

SELECT Code, Description + 'the product is displayed' + <br><br>'To purchase this <a href=/purchaseitem.aspx?' >here</a>

FROM web.dbo.order_codes AS OC
WHERE productName = code


Any ideas how I can get the select statement working?
SB

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-12 : 10:45:29
quote:
Originally posted by sbuser

I am running an insert in a stored procedure, but need tio concatenate on of the fields. How do I do that? Below is an example:

INSERT sam.dbo.product
( productName,
ProdDesc,
TransDateBegin,
TransDateEnd
)

SELECT Code, Description + ' the product is displayed <br><br>To purchase this <a href=''/purchaseitem.aspx?''>here</a>'

FROM web.dbo.order_codes AS OC
WHERE productName = code


Any ideas how I can get the select statement working?
SB



Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

anonymous1
Posting Yak Master

185 Posts

Posted - 2007-11-12 : 10:47:11
looks like you quotes are out of place, have you tried this...
SELECT Code, Description + 'the product is displayed<br><br>To purchase this <a href="/purchaseitem.aspx?">here</a>'
FROM web.dbo.order_codes AS OC
WHERE productName = code

usually it is best to let the web page handle adding tags and the like
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-13 : 02:48:14
<<
usually it is best to let the web page handle adding tags and the like
>>

yes it should be best handled at web page

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-11-13 : 04:19:13
quote:
Originally posted by anonymous1

looks like you quotes are out of place, have you tried this...
SELECT Code, Description + 'the product is displayed<br><br>To purchase this <a href="/purchaseitem.aspx?">here</a>'
FROM web.dbo.order_codes AS OC
WHERE productName = code

usually it is best to let the web page handle adding tags and the like


it will not work using HTML tags in sql query willl generate error of incorrect syntax

try to use nchar or unicode string functions that may work

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA

######################
IMPOSSIBLE = I+M+POSSIBLE
Go to Top of Page
   

- Advertisement -