Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Appending text to a variable in SSIS

Posted on 2007-11-30
5
Medium Priority
?
1,909 Views
Last Modified: 2013-11-30
I have an "Execute SQL Task" in an dtsx package that sends an email using the following code...
EXEC msdb.dbo.sp_send_dbmail
      @profile_name = 'SQL Mail',
       @recipients = 'Test@test.com',
      @copy_recipients = 'test1@test.com',
      @body = ?,
      @subject = 'Some title' ;
This works fine, however I want to add more text to the body (as ? only supplies a single counter value)
I have tried a number of different versions of the code... the following is what I am trying to do...
      @body = 'The number is: ' ?,
However this is not working... neither is @body = 'The number is: ' + ?,
If anyone out there knows how to get around this it would be much appreciated (the input variable ? is of type varchar)
Thanks in advance
0
Comment
Question by:MTSDL
[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
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
digital_thoughts earned 1500 total points
ID: 20381974
What is the error you get when you try:

@body = 'The number is: ' + ?

Just taking a guess it has to do with trying to add a string and a counter value together, you might just need to CAST the counter value to a string first:

@body = 'The number is: ' + CAST(? AS VARCHAR(10))
0
 

Author Comment

by:MTSDL
ID: 20382402
I have tried the above example and there was an error for that as well.

The following is the error that I get...
Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
0
 
LVL 8

Expert Comment

by:digital_thoughts
ID: 20382589
Hmm, ok not sure what is going on... how about giving this a try:

@body = ?,
@body = 'The number is: ' + @body,
0
 

Author Comment

by:MTSDL
ID: 20394472
I have tried the above code and that did not work either...

What I have done is the following... and it works a treat

SELECT 'The number is: ' + cast(count(*) as varchar) AS CountText FROM Table

I pass CountText to the next "Execute SQL Task" and it works fine
0
 
LVL 8

Assisted Solution

by:digital_thoughts
digital_thoughts earned 1500 total points
ID: 20395568
Yes, that would work just fine, any time you need to add a non-string (varchar) value to a varchar you will need to cast or convert it. I should have asked what exactly ? was as it wasn't directly clear in your originally post. Regardless, glad you got it to work.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

721 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