Passing @parameters And TEXT To Xp_sendmail Message!!
Jan 29, 2004
How do you pass parameters and text to the message area... i know how to pass parameters or pass text how do i do both... for example.
Exec master.dbo.xp_sendmail @recipients = 'johndoe' @message = 'hello and @number'
PLZ HELP!!!!!!
View 1 Replies
ADVERTISEMENT
Feb 22, 2008
Hi All,
I want to dynamically generate the SQL Server Reporting Services by passing the query parameter from the url like this :
"http://localhost/Reports/Pages/Report.aspx?ItemPath=%2fDashboardReports%2fHorse_Profile&rs:Command=Render&rcarameters=false&HorseID=117415"
Where horseid id my parameter which is needed by report to generate the required data.
This query paramter value is picked from the text box on my jsp page.
But my problem is when i go to this url it says the message
"The 'HorseID' parameter is missing a value ".
In my report i have disabled the prompt user option , enable the Hide paramter option and has given no default value for this parameter.
I have done a lot of search on this topic. Everybody says that we can pass the values from the url like i am using. But still its not working. This forum is my last hope.
Any body has any idea please give me some idea.
Regards.
View 9 Replies
View Related
Dec 26, 2003
I thought I would post this solution. I searched a long time and didnt see anything about how to solve my problem. After avoiding this and simply building strings I decided to dig in my heels and try and figure this out. Well, maybe I am just slow. :) Anyhow, here is some code that should help a lot of folks with this question...
Function GetProductCategories(ByVal departmentID) As DataSet
'set the connection string (comes from a property in this case)
Dim connection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionStringWeb"))
'set the sql text string notice the @DepartmentID is my parameter. protected from sql injections
Dim strSQL As String = "SELECT * FROM ProductCategory WHERE DepartmentID = @DepartmentID"
'set new command object to strsql and the connection. required
Dim command As New SqlCommand(strSQL, connection)
'set parameters to pass to through with the strsql. required for parameters. you can take this a set further. See commented fields below.
command.Parameters.Add(New SqlParameter("@DepartmentID", departmentID))
'additional set up for parameters if you like...
'command.Parameters.Add("@departmentID", SqlDbType.Int, 4)
'command.Parameters("@departmentID").Value = departmentID
'set SQLDataAdapter to your previously created command object
'this enables your adapter access to your strSQL, connection and parameters
Dim da As New SqlDataAdapter(command)
'set proper name of table for data set based upon departmentID
If departmentID = 1 Then
Dim ds As New DataSet()
da.Fill(ds, "dtCarriers")
Return ds
End If
'set proper name of table for data set based upon departmentID
If departmentID = 2 Then
Dim ds As New DataSet()
da.Fill(ds, "dtProducts")
Return ds
End If
End Function
View 4 Replies
View Related
Jul 20, 2005
I have everything set up with SQL Server 2000 and Outlook 2000 and theprocedure works fine but the message sits in my inbox. When it openthe e-mail it says this message has not been sent. I just click sendand the e-mail sends. Is there any reason I have to manually sent thee-mail after the xp_sendmail procedure works and should send thee-mail itself.ThanksJohn
View 1 Replies
View Related
Jun 18, 2007
Hi I have difficulty in sending message to different reciepients. I am using SSIS package to send in the parameter. If anybody could help to resolve will be great.
Thanks
declare @MailMsg varchar(1000)
select @MailMsg = 'Hi there,
Here are the Documents Nos. and details
Status.
Thank you.'
exec master.dbo.xp_sendmail
@recipients = ?,
@subject = 'Documents Status',
@message = @MailMsg,
@attachments = 'C:MyWorkDocument.XLS'
View 10 Replies
View Related
Mar 3, 2000
Can i send a file as the body of @message
in the extended sp xp_sendmail?
Pls help! thanks for any help.
View 2 Replies
View Related
Sep 13, 2005
Created a SP that uses system function XP_SENDMAIL. I wantto be able to send a HYPERLINK in the email. TheHYPERLINK is created dynamically and generally long in length (exceedsdefault width of 80 characters) and when rendered in the email is splitacross 2 lines. The problem is that when you click on the link itdisregards the part of the link that has been split onto the linebelow.Does anyone know a solution to this - how to extend the width of theemail to wider that 80 characters so that the link is not split over 2lines? I know that you can use the @width parameter when placing themessage in an attatchment, however I want the link to be placed in thebody of the email and not in an attachment.Any help is much appreciated..
View 2 Replies
View Related
Sep 3, 2007
Books Online gives a way to send a message larger than the VARCHAR max of 8000 chars, but the @query argument to xp_sendmail is a simple text string and my data is much more complex, and formatted. Also BOL shows an example using a temporary text file, but it is not clear precisely how you write your insert statements. I tried the following, which writes out all the data and sends it ok except, after each row, there is about a page of blank spaces. What is wrong with my syntax?
SET LANGUAGE British
GO
DECLARE @msgstr VARCHAR(80)
DECLARE @cmd VARCHAR(80)
DECLARE @PMID INT
DECLARE @forename VARCHAR(30)
CREATE TABLE ##texttab (c1 text)
SET @msgstr = 'THE FOLLOWING QUOTES ARE CURRENTLY MARKED AS PENDING:'
INSERT ##texttab SELECT @msgstr
DECLARE C2 CURSOR FOR SELECT ProjMgrID FROM surdba.SVY_QUOTES WHERE StatusID=6
OPEN C2
FETCH NEXT FROM C2 INTO @PMID
WHILE @@FETCH_STATUS = 0
BEGIN
IF @PMID > 1000
SELECT @forename = ISNULL(Forename,' ') FROM surdba.SVY_PERSONNEL_GENERAL WHERE EmployeeID = @PMID
ELSE
SET @forename = ' '
INSERT ##texttab values (RTRIM(@forename))
FETCH NEXT FROM C2 INTO @PMID
END
CLOSE C2
DEALLOCATE C2
INSERT ##texttab values ( ' - This information is autogenerated from the Survey database.')
SET @cmd = 'SELECT c1 FROM ##texttab'
EXEC master.dbo.xp_sendmail @recipients = 'Robin Pearce',
@subject = 'ALL PENDING QUOTES',
@query = @cmd,
@no_header = 'TRUE'
DROP TABLE ##texttab
GO
Would appreciate any help on this one, I do not have time to learn HTML,
thanks
Robin Pearce
View 1 Replies
View Related
Jun 21, 2005
I have looked all over my code and can not find anywhere that I am referencing the xp_sendmail procedure! Here is all the code<code>With sqlCmdUpdateParticipants
.Parameters("@ClassID").Value = ddlClass.SelectedItem.Value
.Parameters("@Person").Value = tbName.Text()
End With
cnCapMaster.Open()
sqlCmdUpdateParticipants.ExecuteNonQuery()
cnCapMaster.Close()</code>I am just getting a couple values and and inserting them into the database. the insert works then I get darn error message. This code worked at one time but it has been about 2 years sense I worked on it so who knows what might have happened sense then.Thanks,Bryan
View 6 Replies
View Related
Jul 20, 2005
Hi everybody,i try to send messages longer than 7990 characters from a text fieldin SSQL2000. Unfortunatly the messages get cut off after 7990character.I did everything which is described in BOL (see below). It does notsolve the problem. Upgraded to newest Outlook Client and tried to sendas an attachment also. No success though.Does anybody have a hint before i contact Microsoft.RegardsYorn Ziesche[color=blue]>E. Send messages longer than 7,990 characters[/color]This example shows how to send a message longer than 7,990 characters.Because message is limited to the length of a varchar (less rowoverhead, asare all stored procedure parameters), this example writes the longmessageinto a global temporary table consisting of a single text column. Thecontents of this temporary table are then sent in mail using the@queryparameter.CREATE TABLE ##texttab (c1 text)INSERT ##texttab values ('Put your long message here.')DECLARE @cmd varchar(56)SET @cmd = 'SELECT c1 FROM ##texttab'EXEC master.dbo.xp_sendmail 'robertk',@query = @cmd, @no_header= 'TRUE'DROP TABLE ##texttab
View 3 Replies
View Related
Jul 20, 2005
Hi, AllI use VB.NET to create a database application, I create a trigger for"Order" table. Every time a order is placed, UnitsOnStock will be reduced on"Inventory" table.If UnitesOnStock < 0, I raise a error "Not enough units on stock", but Idon't know how to pass the error message to VB.NET (ASP.NET). Please help.ThanksKai
View 1 Replies
View Related
Mar 14, 2008
Hi,
how to pass paremeters in sqldataadapter? here iam checking authentication using sqlcommand and datareader
like that if iam checking authentication using dataset and sqldatareader how to use parameters?
SqlConnection cn = new SqlConnection("user id=sa;password=abc;database=xyz;data source=server");
cn.Open();
// string str = "select username from security where username='" + TextBox1.Text + "'and password='" + TextBox2.Text + "'";
string str = "select username from security where username=@username and password=@password";
SqlCommand cmd = new SqlCommand(str, cn);
cmd.Parameters.AddWithValue("@username", TextBox1.Text);
cmd.Parameters.AddWithValue("@password", TextBox2.Text);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
Session["username"] = TextBox1.Text;
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
}
else
{
Label1.Visible = true;
Label1.Text = "Invalid Username/Password";
}
-------------------------------------------------------------------------------------
like that if iam checking authentication using dataset and sqldatareader how to use parameters?SqlConnection cn = new SqlConnection("user id=sa;password=abc;database=xyz; data source=server");
cn.Open();ds = new DataSet();
string str = "select username from security where username=@username, password=@password";da = new SqlDataAdapter(str, cn); //how to pass parameters for that
da.Fill(ds, "security");
Response.Redirect("dafault2.aspx");
View 2 Replies
View Related
Apr 17, 2004
I have a dts package file. I am able to execute the file thro C#. I want to pass userid, password, datasource through program. How to do this?
DTS.PackClass package = new DTS.PackClass();
string filename = @"c:abc.dts";
string password = null;
string packageID = null;
string versionID = null;
string name = "DTSPack";
object pVarPersistStfOfHost = null;
package.LoadFromStorageFile(filename, password, packageID,
versionID, name, ref pVarPersistStfOfHost);
package.Execute();
package.UnInitialize();
package = null;
Thanks
Jtamil
View 2 Replies
View Related
May 30, 2006
Still need help passing a criteria parameter query from a SQL Function (i.e. @StartDate) to a report header in Access Data Project where header = 'Transactions As Of [StartDate].
If anyone knows anywhere I can get help on this, I would really appreciate it. Thanks.
View 1 Replies
View Related
Oct 2, 2006
More of a general "Streams" question than broker specific, but this is all being done in the context of Broker passing the messages around. The use of Streams & Encoding seems to be my problem and I'm not as familiar with Streams as I am with other areas of the Framework... Any advice would be appreciated.
At this point, I've created my own objects/stored procedures based loosely on the ServiceBrokerInterface class provided in the SQL Server samples. Some of this was done for simplification and as a learning exercise, but also to ensure that all of the SQL operations are being done via Stored Procedures and not inline SQL. This was done to adhere to our existing security policy used on this project.
In this "interface" I've built, I have a [BrokerMessage.cs] class which is meant to have a few additional pieces of functionality beyond what the MS provided version had supplied.
1st... A constructor for accepting either String or XmlDocument as the "content"
2nd... Methods to return either a XmlDocument or a simple String.
Since all of the Broker functionality is defined as using VARBINARY(MAX) in my stored procedures, I don't believe I have any problems at that level. It's simply a binary blob to Broker.
In my constructor for accepting String or XmlDocuments, I attempted to use the following...
public BrokerMessage(string type, XmlDocument contents)
{
m_type = type;
m_contents = new MemoryStream(EncodingProvider.GetBytes(contents.InnerXml));
}
My understanding was that MemoryStream is derived from Stream so I can implicitly cast it. The "EncodingProvider" is a static member set as follows:
public static Encoding EncodingProvider = Encoding.Unicode;
This way I ensure that internal & external code can all be set to use the same encoding and easily changed if necessary. I was hoping to avoid using Unicode since the rest of the application does not require it, but from my understanding all Xml documents in SQL Server are Unicode based, so this should be a better encoding choice for any processing that may potentially occur within SQL Server itself.
In my methods to return the various forms of the "Stream", I have the following code... The ToBytes() method is what is used to pass intot he stored procedure parameter that is defined as VarBinary and expecting a byte array. One area of concern is that the Read method accepts an INT for the length, but the actual Length property is a LONG. I'm sure there's a better way to handle this and I would welcome any advise there.
/// <summary>
/// Used to convert from a Stream back to a simple Byte array.
/// </summary>
/// <returns></returns>
public virtual byte[] ToBytes()
{
byte[] results = new byte[this.Contents.Length];
this.Contents.Read(results, 0, (int)this.Contents.Length);
return results;
}
/// <summary>
/// Used to convert from a Stream back to a simple String.
/// </summary>
/// <returns></returns>
public new string ToString()
{
byte[] buffer = this.ToBytes();
String results = EncodingProvider.GetString(buffer);
return results;
}
/// <summary>
/// Used to convert from a Stream back to a simple XmlDocument.
/// </summary>
/// <returns></returns>
public virtual XmlDocument ToXmlDocument()
{
XmlDocument results = new XmlDocument();
results.InnerText = this.ToString();
return results;
}
View 5 Replies
View Related
Jul 28, 2006
A little new to ASP.NET pages, and I'm trying to pass some parameters to a SQL 2000 Server using a TableAdapter, code is as follows:
------
TestTableAdapters.test_ModemsTableAdapter modemsAdapter = new TestTableAdapters.test_ModemsTableAdapter();
// Add a new modem
modemsAdapter.InsertModem(frmRDate, frmModem_ID, frmProvisioning, strDecESN );
--------
And the error I get when loading the ASP.NET page is as follows:
Compiler Error Message: CS1502: The best overloaded method match for 'TestTableAdapters.test_ModemsTableAdapter.InsertModem(System.DateTime?, string, string, string)' has some invalid arguments
---------------
Now I realized the four strings that I am trying to pass to the server refer to ID's on Textboxes on the web page. Not sure if that might be the problem for databinding... ? Or is it my statement for the adapter?
-Ed
View 4 Replies
View Related
Dec 7, 2006
The SQL for a dataset in ASP.NET 2.0 is as follows....
SELECT DISTINCT StudentData.StudentDataKeyFROM Student2Roster INNER JOIN StudentData ON Student2Roster.StudentDataRecID = StudentData.StudentDataRecIDWHERE (Student2Roster.ClassRosterRecID IN (@ClassRosterRecIDs)
ClassRosterRecIDs are giuds
At design time i use 'b2cf594d-908b-4c0c-a67f-6364899a4d42', '2e0b3472-d3f0-4a54-94af-bfc0a99525d9' as the parameter and it works in the designer but not at runtime.
At runtime I get the error Conversion failed when converting from a character string to uniqueidentifier.
If I leave the quotes off and only use 1 value like b2cf594d-908b-4c0c-a67f-6364899a4d42 it works.How can I use multiple guids as an IN parameter like 'b2cf594d-908b-4c0c-a67f-6364899a4d42', '2e0b3472-d3f0-4a54-94af-bfc0a99525d9'?
Thanks
View 2 Replies
View Related
Jul 22, 2007
Hi,I want to pass parameter in to LIKE functionIs there anyway to do thatThanks,Janaka
View 6 Replies
View Related
Apr 10, 2008
Hi
I'm trying to add 2 date parameters to the where caluse but not sure how to structure it:
Can anybody help?
Public Function GetCategoryPerformance(ByVal PriorityType As String) As DataSet
'*******************************************************
'This web service will return a specific row for a table
'*******************************************************Dim cn As New SqlConnection("data source=CADTRAINING;persist security info=True;initial catalog=pathwaysreporting;user id=cad;password=cad;")
Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT * from sp_category_performance where where priority = '" & PriorityType & "'", cn)Dim ds As DataSet = New DataSet
Try
da.Fill(ds, "CategoryPerformance")Catch ex As Exception
Throw New Exception(ex.Message)
End TryReturn ds
End Function
End Class
View 2 Replies
View Related
Mar 10, 2005
Hello All,
I am executing a DTS package from an asp page using the following code. I would like to also pass DTS Global variables along. i assume this is possible but can't seem to find an example.
Set oPkg = Server.CreateObject("DTS.Package")
oPkg.LoadFromSQLServer "HOFDBMCRM4","TraubGar","ripley",DTSSQLStgFlag_Default,"","","","DSC_CalculateBOS"
oPkg.Execute()
Thanks, Gary
View 1 Replies
View Related
Aug 30, 2001
Hi,
I would like to pass parameters from isql command line to an input query file. I am working on SQL Server 7.0. How can I accomplish this?
My eg. is like this:
> isql.exe (all the server options etc.,) /iInputfile /oOutput file
I need the output depend on the query given in the input file with the query depending on the parameter I supply on the command line.Thanks for your help in advance.
thanks,
Sravan.
View 1 Replies
View Related
Jul 21, 2000
I'm trying to execute this statement but due to some missing paremters its creating table in that fashion
Table created = '+@string+'_'+@string1+'
but I want table to be create as what parameters passed, can you have a look pls...
exec sp_test 'master','table'
Starts here-----------
if exists (select * from sysobjects where id
= object_id(N'[dbo].['+@string+'_'+@string1+'])
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
Drop table [dbo].['+@tblName+'_'+@table1+']
CREATE TABLE [dbo].['+@string+'_'+@string1+']
(
[HESClrId] [nvarchar] (20) NULL ,
[HESClrName] [nvarchar] (60) NULL ,
[HESClrSeq] [smallint] NULL
)
ON [PRIMARY]
View 1 Replies
View Related
Sep 18, 2002
Can I pass a parameter to a view? Can something like this even be done?
CREATE view co_interlinks1
AS
SELECT [TDirectorships].[IDDir], [TDirectors].[DirLName] + ', ' + [TDirectors].[DirFName] AS DirectorName, [TDirectorships].[Ticker], [TCompanies].[CompanyName]
FROM TDirectorships
INNER JOIN TCompanies
ON [TCompanies].[Ticker]=[TDirectorships].[Ticker]
INNER JOIN TDirectors
ON [TDirectorships].[IDDir]=[TDirectors].[IDDir]
WHERE [TDirectorships].[IDDir] in (SELECT [TDirectorships].[IDDir]
FROM TDirectorships
WHERE Ticker=@Ticker)--This line requires a variable value corresponding to Ticker for the chosen company
and [TDirectorships].[Ticker] <> =@Ticker --This line requires a variable value corresponding to Ticker for the chosen company
View 2 Replies
View Related
Oct 24, 2005
Hi
I created a report based on category,time and stores as report parameters.The datasets are created by using mdx queries and the provider I selected is olap services.I would like to add a bar chart in the layout and the resultant chart should be based on the selected parameters.I am not able to get this.First of all is it possible? If so, what should I do in the chart properties?
Regards
Ranjit
View 2 Replies
View Related
Mar 1, 1999
Is it possible to pass a parameter to an NT shell batch script when using the xp_cmdshell extended stored procedure?
View 1 Replies
View Related
Mar 20, 2008
Hi,
I have a requirement to load tables in the database from files on a shared server (lets say 50 tables from 50 files). I do not want to hardocde the file path anywhere in the package since this would mean changing 50 packages everytime the path changes (say when moving to to a diff server).
In SQL Server 2000, I used a .ini file to pass the path and used a Dynamic properties task to set run time variables. That way, evertime the path changes, I only had to change 1 ini file and all packages picked up the new path from it. How do I do this in SQL Server 2005 ?
Appreciate any assistance / suggestion in this regard.
Thanks,
Bhaskar
View 3 Replies
View Related
Mar 20, 2008
Hi,
I have a requirement to load tables in the database from files on a shared server (lets say 50 tables from 50 files). I do not want to hardocde the file path anywhere in the package since this would mean changing 50 packages everytime the path changes (say when moving to to a diff server).
In SQL Server 2000, I used a .ini file to pass the path and used a Dynamic properties task to set run time variables. That way, evertime the path changes, I only had to change 1 ini file and all packages picked up the new path from it. How do I do this in SQL Server 2005 ?
Appreciate any assistance / suggestion in this regard.
Thanks,
Bhaskar
View 8 Replies
View Related
May 30, 2008
How does we pass dynamic number of parameters to a procedure?
Eg.
DECALRE @IDs varchar(50);
SET @IDs = '1,2,3'
SELECT Description FROM MyTable WHERE ID IN (@IDs )
Here ID is int. When I tested this, it shows an error 'Cannot covert '1,2,3' to int'. No errors while it is one number ie '1'
How I can manage this type of problem in a stored procedrue that receive the @IDs as parameters?
View 1 Replies
View Related
May 22, 2007
Hello Friends,
I have a report (Say Report 1)which is asking for a multivalue parameter Period. The user selects three period from the dropdown list available for the Parameter. Lets say that the user select 0407,0507,0607. Now is this report 1 there is a particular field which is linked to another sub report. So if the top level Report 1 supplies the revenue for 3 regions say for the periods selected then clicking on any of the regions would open a second detailed report, say Report 2 for the three periods as selected.
Till this everything is fine.
Now the problem is that in this detailed Report 2 there would be a particular text box as "Click here to naviagate back to parent report". So that when the user clicks on this cell he is taken back to the parent report, Report 1 which was originally generated for the 3 periods.
Can anyone please advise as to how the Multivalue Parameter which was passed from Report 1 to Report 2 can again be looped back to Report 1 from Report 2.
Thanx Friends,
Raktim
View 2 Replies
View Related
Mar 10, 2008
I have an OLE DB Source that talks to an Oracle Db and returns back some data. I need to be able to pass some parameters to my query from the SSIS variables.
How can accomplish this ? Do I need to create a stored proc in my Oracle DB..is that the only way I can pass parameters ?
Is so how ?
Any examples would be really appreciated
Thanks
Smx
View 13 Replies
View Related
May 31, 2007
Hi, I've read some threads in regards to passing report parameters through the 'URL' but I am struggling to fully understand. To keep things simple I have 1 report parameter, named par_pub which brings back either ww06 or ww07. What I require is to click on a hyperlink and it directs me to my report and then populates the par_pub paramerter with ww07.
I am trying the below
http://emp6/Reports/Pages/Report.aspx?ItemPath=%2fTest+Reports%2fIT+Dev%2fSales+Summary+Detail&prefixar_pub=%WW07%
The part in bold is the location + name of the report and the later is where I am trying to pass the parameter. Can anyone please help as this is not working.
Thanks
View 10 Replies
View Related
Jan 14, 2008
How can we pass variables by reference to a UDF? Is there any way in SQL Server to achive this objective?
View 2 Replies
View Related
Nov 12, 2007
Hi,
I have a problem getting the URL string right to pass parameters from one report to another
This is the URL string I have set in the Navigation property of my text box:
"http://SQL/Reportserver$SQL2005/Pages/Report.aspx?%2fEarlyWarning2%2fratio+reports+-+test%2freport_upper_lower_benchmark_ratio1&rs:Command=Render&rcarameters=false
&company="&Parameters!company.Value.ToString()&Parameters!year.Value.ToString()&Fields!ratioName.Value.ToString()
The first thing is that when I just want to view the report say, with parameters hidden, I get this URL
http://reportserver/?%2fEarlyWarning2%2fratio+reports+-+test%2freport_upper_lower_benchmark_ratio1&rs%3aCommand=Render&rc%3aParameters=false
with the message "Internet Explorer cannot display the webpage"
Why does the first part of the URL change?
If I run it with just one parameter, company, I get the same error message with this URL :
http://reportserver/?%2fcompany.Value.ToString()&rs%3aCommand=Render&rc%3aParameters=false&company=%22
It looks like no value for the company parameter being passed
Any suggestions appreciated
Ruth
View 9 Replies
View Related