"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression"..It is about a Stored Procedure, which not only should output the number of opportunities with status "Pending" or "Accepted" but also the name of the opportunities with these statuses. Following points:
1. The SELECT that outputs the names of the opportunities may in some cases return more than one value. I created then the CURSOR CUR_TEST.
2. The code should return the names of Opportunities, namely after "The opportunities are:" and these must be sent to the recipients of an email. How can I do this, so the Names of the Opportunities and the rest of the email can be sent by email?. I mean, the concatenation with SET or SELECT doesn't work. I get as email only the output of the last row of the SELECT with cursor CUR_TEST.
I'm getting the error "No recepient is specified".
I have set up a dataflow from a select statement into a record set, then have that dataflow point to a ForEach group with a mail task in it. I have set up variables for the username and subjectline. So in the mail task I have no value in the To: line because I specify an "http://www.sqlis.com/59.aspx">http://www.sqlis.com/59.aspx exactly.
I couldn't figure out how to included screen shots.
I want to use ssis to export data from relational tables in sql server 2005 and import them into an xml column in sql server 2005.
Any suggestions for the best way to do this.
I created an datareader source using adventure works with the sql command "SELECT * FROM purchasing.vendor FOR XML RAW"
I then created a sql server destination with and mapped the output from above to an xml column.
I get the following error
Error: 0xC0202009 at Data Flow Task, SQL Server Destination [596]: An OLE DB error has occurred. Error code: 0x80040E14.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E14 Description: "XML parsing: line 1, character 2033, unexpected end of input".
Is there a better way to attack this? I'd prefer not to need to send to the file system, etc.
I have posted this on previous forums, but the below code is a VB.net CLR stored proc that will accepts two parameters, a SELECT.... FOR XML query and a file path, and saves the resulting xml result into a file specified by the parameter. After compiling the VB code into a .dll than the T-SQL code to import the assembly, create the CLR proc and test it is included underneath. Hope some will find this useful
Code Snippet 'Requires the Trial or Release version of Visual Studio .NET 2005 Professional (or greater). Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Data.SqlTypes Imports Microsoft.SqlServer.Server Imports System.Xml
Partial Public Class outputxml <Microsoft.SqlServer.Server.SqlProcedure()> _ Public Shared Sub outputxml(ByVal XmlData As SqlXml, ByVal Filename As SqlString) 'Create the variables to hold the values that are supplied by the parameters 'input by the stored procedure Dim xmlDoc As New XmlDocument() Dim output As SqlPipe = SqlContext.Pipe() Try 'Load the result set into the XmlDoc Variable and then save the results in the 'path provided by the stored procedure. The values are provided by the 'input parameters of the stored procedure xmlDoc.LoadXml(XmlData.Value) xmlDoc.Save(Filename.Value) Catch ex As Exception 'If an error occurs catch the message and pipe it back to SQL output.Send(ex.Message.ToString) End Try End Sub End Class
T-SQL CODE BEGINS HERE
/*Alter the database to set trustworthy on in order
to allow the ability to set the assembly to external
I have a job that emails out shipment notifications at the end of the day to our customers. The problem I have is I don't understand why the same email is sending out twice within a minute of each other when the job is only scheduled to run once. If I take the code out of the step and run it in management studio it only emails once. I attached the code for one customer for reference. We are running SQL 2008 on a VM sending to an exchange 2010 server.
DECLARE @tableHTML NVARCHAR(MAX) ; SET @tableHTML =N'<H1>XYZ Company ASN For ' + CONVERT(VARCHAR(10), GETDATE(), 101) + ' </H1>' + N'<table border="1">' + N'<tr><th>Vendor</th><th>Delivery Date</th>' + N'<th>Purchase Order Number</th><th>Item Number</th><th>Item Description</th>' + N'<th>Quantity Shipped</th><th>UOM</th><th>BOL Number</th>'
Is there anyway to  send excel file from ssis using send mail task without saving the excel file locally. I need to automate the process which involves loading the excel file from the database and send it to some people.Â
I have attempted to report out errors at the end of an ETL process by alerting supporting DBAs of errors using the SSIS "Send Mail Task". Task completes along with the sequenced packages, but does not mail anything out. No logic at this time for trigger, just success from the previous task triggering the task to send mail. I also get no errors in the output, and I get no output indicating the send mail task fired, but it does go "green". Do I have to enable database mail and have privileges?
Component Configuration:
SMTP Connection Manager - SMTP Server: arsocex02
Send Mail Editor -
From: messerj@arsocdev.bdev.lab.mil To: sanderss@arsocdev.bdev.lab.mil MessageSourceType: Direct Input Expression: MessageSource = "Package>>> " + @[System:ackageName] +" was executed at>>> " + (DT_WSTR, 40) @[System:tartTime] + " by user>>> " + @[System::UserName] + " on Machine>>> " + @[System::MachineName] + " Errors reported to ERRORS_COURSE_CLASS_STATUS_T: " + (DT_WSTR, 50) @[User::ErrorCourseClassStatus]
Is there a way to get two or more users to recieve net send messages? Currently we have one user that is receiving the messages and we need another admin to receive them as well.
Hi all, can i send an email through SQL? i don't want to use third party software. Also, i can't configure the customer's db server. It is possible to send an email without much configuration. If configuration needed, is it possible to configure through SQL script? thx
I know that is possible to programmatically send an e-mail with the command xp_sendmail, but i want to know if it's possible to programmatically send a Net Send message.
I have a datetime field in sql database in which dates are stored in format 'mm/dd/yyyy'. What i want is to send them BD greetings checking with the current date. How can i acheive this in query ?
Hi, I need to select a table from my database and send the table as an email message to a person every 10am because the table changes every day. How to it?
On a Windows 2000 Server in MYDomain I can do the followingsuccessfully:Net Send JoeUser "test"However on a Windows Server 2003 (Standard Edition) in MyDomain I get:An error occurred while sending a message to JoeUser.The message alias could not be found on the network.More help is available by typing NET HELPMSG 2273.If I enter: net send /DOMAIN:MyDomain joeuser "test"net send comes back with:The message was successfully sent to domain MyDomainBUT... no popups are received.Is there something common to a Windows Server 2003 server that I needto configure to get this to work?How does this relate to SQL Server 2000? I figure that if I can get itto work via a command prompt that it will work for notification as well-- which at this point it doesn't.Thanks for any help.RBollinger
I'm a newby and I have a quick question. I have set up this procedureto run as a job. I can create a block and have it populate the table,but I need to be alerted via email when the table is being populated. Ido not know what step/s am I missing. Here is the scripts I ran:CREATE TABLE BlockMonitorInfo(spid smallint,blocked smallint,waittype binary,InfoTime datetime)go/*********creates a control table that lets you turn the backgroundprocess on and off**********/CREATE TABLE BlockMonitorControl(BlockMonitorOn tinyint)go/**********populates the control table and initially turns on thebackground process******/INSERT INTO BlockMonitorControlVALUES (1)go/*StartBlockMonitor accepts one datetime paramter that controls thesampling delay for capturing blocking information*/drop PROC StartBlockMonitorgoCREATE PROC StartBlockMonitor@DelayTime char(9)ASDECLARE @CurrentInfoTime datetime-- Set the control flag in BlockMonitorControl = Onupdate BlockMonitorControl set BlockMonitorOn = 1-- Capture blocking lock info until the control flag is set = false-- We set it off by running StopBlockMonitor which we'll create soon.WHILE (SELECT BlockMonitorOn from BlockMonitorControl) = 1BEGINSELECT @CurrentInfoTime = getdate()INSERT INTO BlockMonitorInfo (spid, blocked, waittype, InfoTime )SELECTspid, blocked, waittype, @CurrentInfoTimeFROMmaster..sysprocesses (nolock)WHEREblocked <> 0WAITFOR delay @DelayTimeENDgo/*StopBlockMonitor turns off the capture of blocking info by setting thecontrol flag in BlockMonitorControl = off*/DROP PROC StopBlockMonitorgoCREATE PROC StopBlockMonitorASUPDATE BlockMonitorControl SET BlockMonitorOn = 0goSELECTBlockMonitorInfo.*FROMBlockMonitorInfo,(SELECT distinct InfoTime FROM BlockMonitorInfo)BlockChainTimeWHEREBlockMonitorInfo.InfoTime =BlockChainTime.InfoTimeand Blocked not in(SELECT spidFROM BlockMonitorInfoWHERE InfoTime =BlockChainTime.InfoTime)This last query is what I have set up in a job, but I need the job toalert us when the table gets new information added.Thank you for the assistance!
xp_sendmail has died on our SQL Server, I get error "xp_sendmail:failed with mail error 0x80004005" if I try using it.I believe that the reason that this has happened is because the SQLServer service account is unable to send mail, as follows:If I log on to Outlook Web Access as the SQL Server service account(SVC_SqlServer) I am able to receive mail. However, any mail sent fromthis account simply dissapears.It appears in the Sent items folder (in OWA for the SVC_SqlServeraccount) but the recipient (me, in this case) never receives it!Does anyone know why this account is unable to send mail?Help!eddiec :-)
How can I Send Mail with the query result having multiple rows. What type of dataflow destination is correct (recordset, datareader). The Send Mail task is working correctly. But, the message is blank without any result set.
1) sql connection SMTP Connection Manager 1 (windows authenditacaion/smtp both itried i was selected) 2) from/to /cc : i entered som mail ids of yahoo 3) subject : Hi koti how r u ,i am fine here
4) message source type : variable SMTPSERVER: it is just string with null value i was declare a variable ok fine then
how to use the send mail in the foreach loop example please send me
actually i m working on a store procedure in which end of the procedure when task complete it's send email to specific person, but i m having a problem using this function.
it's work fine when the outlook is configure on the server, but is there any way to send email rather then configure outlook on the server just chk internet is working send email on behalf of server, i have more then 2 servers and outlook is configure only one server and i don't want to configure outlook on other server due to work load on server.
This is my procedure which I need to send the Data into Database, But it does not generate any error and it does not send the information into Database, May I have done wrong, any one to look on that please. Sub Add_To_Cart(ByVal Src As Object, ByVal Args As EventArgs) Dim FVProductID As Label = FormView1.FindControl("ProductID") Dim FVProductName As Label = FormView1.FindControl("ProductName")Dim FVProductPrice As Label = FormView1.FindControl("ProductPrice") Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim sql As String Dim SQLAddString As String DBConnection = New SqlConnection("Data Source=MANDARISQLEXPRESS;Initial Catalog=SHOES;Integrated Security=True") DBConnection.Open() If Not Session("OrderID") Is Nothing Then sql = "SELECT Count(*) FROM ShoppingCart " & _ "WHERE OrderID = '" & CType(Session("OrderID"), String) & "' " _ & "AND ProductID = '" & FVProductID.Text & "'" DBCommand = New SqlCommand(sql, DBConnection)
If DBCommand.ExecuteScalar() = 0 Then SQLAddString = "INSERT INTO ShoppingCart (OrderID, ProductID, OrderDate, ProductName, ProductQnty, ProductPrice) VALUES (" & _ "'" & Session("OrderID") & "', " & _"'" & FVProductID.Text & "', " & _ "'" & Today & "', " & _"'" & FVProductName.Text & "', " & _ "'" & FVProductPrice.Text & "', 1)"DBCommand = New SqlCommand(SQLAddString, DBConnection) DBCommand.ExecuteNonQuery() End If End If DBConnection.Close()
Sub Add_To_Cart(ByVal Src As Object, ByVal Args As EventArgs)
Dim FVProductID As Label = FormView1.FindControl("ProductID") Dim FVProductName As Label = FormView1.FindControl("ProductName") Dim FVProductPrice As Label = FormView1.FindControl("ProductPrice")
Dim DBConnection As SqlConnection Dim DBCommand As SqlCommand Dim sql As String Dim SQLAddString As String
DBConnection = New SqlConnection("Data Source=MANDARISQLEXPRESS;Initial Catalog=SHOES;Integrated Security=True") DBConnection.Open() If Not Session("OrderID") Is Nothing Then
I'm try to use a SqlDataSource control for binding data (stored procedure) to a GridView control. But I only get the error message below. What am I doing wrong? ----------- Error message ----------------------Procedure or function 'StatisticCustomers' expects parameter '@From', which was not supplied. ------------- Customer.aspx -------------------- From <asp:TextBox id="txtDateFrom" CssClass="datebox" runat="server"></asp:TextBox> To <asp:TextBox id="txtDateTo" CssClass="datebox" runat="server"></asp:TextBox> Min: <asp:TextBox id="txtMinimumOrders" CssClass="" runat="server"></asp:TextBox> <asp:GridView ID="grdvwCustomers" AllowPaging="True" AllowSorting="True" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundField DataField="UserId" HeaderText="UserId" SortExpression="UserId" /> <asp:BoundField DataField="Column1" HeaderText="Column1" ReadOnly="True" SortExpression="Column1" /> <asp:BoundField DataField="Items" HeaderText="Items" ReadOnly="True" SortExpression="Items" /> <asp:BoundField DataField="Column2" HeaderText="Column2" ReadOnly="True" SortExpression="Column2" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:LocalSqlServer %>" SelectCommand="StatisticCustomers" SelectCommandType="StoredProcedure" runat="server"> <SelectParameters> <asp:ControlParameter ControlID="txtDateFrom" Name="dtFrom" PropertyName="Text" Type="DateTime" /> <asp:ControlParameter ControlID="txtDateTo" Name="dtTo" PropertyName="Text" Type="DateTime" /> <asp:ControlParameter ControlID="txtMinimumOrders" Name="iMinimumOrders" PropertyName="Text" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> ALTER PROCEDURE [dbo].[StatisticCustomers] (@From datetime, @To datetime, @MinimumOrders int )AS SELECT Orders.UserId, 'name', COUNT(*) AS Items, SUM(OrderDetail.Subtotal) FROM Orders INNER JOIN OrderDetail ON Orders.OrderId = OrderDetail.OrderId WHERE DateCreated > @From AND DateCreated < @To GROUP BY Orders.UserId ORDER BY Items DESC Regards, Sigurd
I have a database query which will return a single value
SELECT COUNT(DISTINCT(Level_id)) FROM RoleSkill WHERE Route_ID = 1
obviously this will return only a single value and not an array of data like most database queries, therefore i would like it to be sent directly to an integer variable.
I tried doing this directly with a sqlcommand but get error that it cannot be converted to integer. Is there a good way of solving this problem?
I need to set up SQLMail togheter with Notes, We have SMTP server and profiles but I can´t get it to work. SQL sends the mail but it disappears into the cyberspace.. Someone help me pls...
I have created some stored procedures that I wish to share with another user in another database. How can I extract this code, other than cut and paste, since I have quite a few? Is it possible to duplicate database object "stored procedures"? How about a script that would recreate them in the target database?
I'm trying to figure out how the SQL Agent sends email through jobs using the notification option for operators. I have had little success using SQL mail so I want to use an alternate such as blat. I have not been able to find where the SQL jobs are actually sending the mail. Can someone help please. OI have checked the system stored procedures without suscess. I'm using SQL2000.