Concatenating string with int column

Concatenating string with int column

Post by J.S. » Sun, 13 Aug 2000 04:00:00



I have a SQL 7 View with this code:

SELECT BannerID, Image, URL, Shown, Clicked,
   '<a href="RedirectMe.asp?URL=' + URL + '&BannerID=' + BannerID
    + '"target="_blank"><img src="' + Image + '"></a>' AS Banner
FROM Banners

When I try to open this View I get the following error:

Syntax error converting the nvarchar value '<a
href="RedirectMe.asp?URL=admin.asp&BannerID=' to a column of data type int.

Would anyone have an idea how to solve this?  I think I need to use CAST or
CONVERT but I am not sure how.

--
Thanks,
J.S.

 
 
 

Concatenating string with int column

Post by Alla » Mon, 14 Aug 2000 04:00:00


...+ CONVERT(char(),int datafield) +...



Quote:>I have a SQL 7 View with this code:

>SELECT BannerID, Image, URL, Shown, Clicked,
>   '<a href="RedirectMe.asp?URL=' + URL + '&BannerID=' + BannerID
>    + '"target="_blank"><img src="' + Image + '"></a>' AS Banner
>FROM Banners

>When I try to open this View I get the following error:

>Syntax error converting the nvarchar value '<a
>href="RedirectMe.asp?URL=admin.asp&BannerID=' to a column of data type int.

>Would anyone have an idea how to solve this?  I think I need to use CAST or
>CONVERT but I am not sure how.

>--
>Thanks,
>J.S.


 
 
 

Concatenating string with int column

Post by J.S. » Mon, 14 Aug 2000 04:00:00



Quote:> ...+ CONVERT(char(),int datafield) +...

I tried the following:

SELECT BannerID, Image, URL, Shown, Clicked,
   '<a href="RedirectMe.asp?URL=' + URL + '&BannerID=' + CONVERT(char(),int
BannerID) + '"target="_blank"><img src="'
    + Image + '"></a>' AS Banner
FROM Banners

but it gives me this error:

"Unable to parse query text"

J.S.



> >I have a SQL 7 View with this code:

> >SELECT BannerID, Image, URL, Shown, Clicked,
> >   '<a href="RedirectMe.asp?URL=' + URL + '&BannerID=' + BannerID
> >    + '"target="_blank"><img src="' + Image + '"></a>' AS Banner
> >FROM Banners

> >When I try to open this View I get the following error:

> >Syntax error converting the nvarchar value '<a
> >href="RedirectMe.asp?URL=admin.asp&BannerID=' to a column of data type
int.

> >Would anyone have an idea how to solve this?  I think I need to use CAST
or
> >CONVERT but I am not sure how.

> >--
> >Thanks,
> >J.S.

 
 
 

Concatenating string with int column

Post by J.S. » Mon, 14 Aug 2000 04:00:00


Ok, I got it working.  I'll improve it later with LTrim, etc.

SELECT BannerID, Image, URL, Shown, Clicked,
   '<a href="RedirectMe.asp?URL=' + URL + '&BannerID=' + CONVERT(char(1),
    BannerID)
   + '"target="_blank"><img src="' + Image + '"></a>' AS Banner
FROM Banners

Thanks, Allan!

--
Thanks,
J.S.




> > ...+ CONVERT(char(),int datafield) +...

> I tried the following:

> SELECT BannerID, Image, URL, Shown, Clicked,
>    '<a href="RedirectMe.asp?URL=' + URL + '&BannerID=' +
CONVERT(char(),int
> BannerID) + '"target="_blank"><img src="'
>     + Image + '"></a>' AS Banner
> FROM Banners

> but it gives me this error:

> "Unable to parse query text"

> J.S.

 
 
 

1. Pad strings/concatenate columns to simulate data columns in ASP select box with SQL Server 2K

I'm trying to display several columns worth of information in an ASP
select box, but am not having much luck.

Since I cannot actually display columns, I've set the font to a
non-proportional font and am concatenating values together along with
blank spaces to get the columns to line up.  Is there an easier way to
do this?

Is there a simple function PADR() or something like that that I can
use in ASP/VB Script to pad a string with spaces?

The data I'm using sits in a SQL Server database, so if there isn't an
easy way to do this in ASP, is there a simple T-SQL solution?

--
HTH

Dale Fye

2. ODBC, ORACLE, VC++

3. Concatenate column values into a string?

4. VB 6 Program Operating Under Windows XP

5. Getting a Single-Column Recordset as a Concatenated String

6. CRIPES! HOW DO I CHANGE 0181 TO 020 8

7. Concatenate TEXT column + 'string'

8. number of Affected rows

9. Concatenating a column of values into a string?

10. CONCATENATE A SERIES OF STRINGS TO RETURN A SIGNE COLUMN

11. Create a view to display concatenated columns in a long string

12. Unable to concatenate a string to a column