Xp_sendmail Refuses To Run Query

May 23, 2000

I'm new to using xp_sendmail, and here is what I get...
=====================================
EXEC master..xp_sendmail
@recipients = 'amccollough',
@subject = 'EMAIL TEST',
@message = 'This is a test'
(result="Mail Sent", it works fine)
=====================================
But this one fails...
=====================================
EXEC master..xp_sendmail
@recipients = 'amccollough',
@subject = 'EMAIL TEST',
@message = 'This is a test',
@query = 'SELECT * FROM INFORMATION_SCHEMA.TABLES'
(result="Server: Msg 17969, Level 16, State 1, Line 0
Unable to login to SQL Server.")
=====================================
I've tried tons of variations with adding in @dbuse and @set_user, and am totally lost as what to try next. Anybody have suggestions?

View 1 Replies


ADVERTISEMENT

Query Works In 'test Query' But Refuses To Show Up In The Datagrid On A Web Page - Urgent!

Mar 28, 2007

Hey, i've written a query to search a database dependant on variables chosen by user etc etc. Opened up a new sqldatasource, entered the query shown below and went on to the test query page. Entered some test variables, everything works as it should do. Try to get it to show in a datagrid on a webpage - nothing. No data shows.
 SELECT dbo.DERIVATIVES.DERIVATIVE_ID, count(*) AS Matches
FROM dbo.MAKES INNER JOIN
dbo.MODELS ON dbo.MAKES.MAKE_ID = dbo.MODELS.MAKE_ID INNER JOIN
dbo.DERIVATIVES ON dbo.MODELS.MODEL_ID = dbo.DERIVATIVES.MODEL_ID INNER JOIN
dbo.[VALUES] ON dbo.DERIVATIVES.DERIVATIVE_ID = dbo.[VALUES].DERIVATIVE_ID INNER JOIN
dbo.ATTRIBUTES ON dbo.[VALUES].ATTRIBUTE_ID = dbo.ATTRIBUTES.ATTRIBUTE_ID
WHERE ((ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID1 and (@VAL1 is null or VALUE = @VAL1)) or
(ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID2 and (@VAL2 is null or VALUE = @VAL2)) or
(ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID3 and (@VAL3 is null or VALUE = @VAL3)) or
(ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID4 and (@VAL4 is null or VALUE = @VAL4)) )
GROUP BY dbo.DERIVATIVES.DERIVATIVE_ID
HAVING count(*) >= CASE WHEN @VAL1 IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN @VAL2 IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN @VAL3 IS NOT NULL THEN 1 ELSE 0 END +
CASE WHEN @VAL4 IS NOT NULL THEN 1 ELSE 0 END -2
ORDER BY count(*) DESC

 Here is the page source
 
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DevConnectionString1 %>"
SelectCommand="&#9;SELECT dbo.DERIVATIVES.DERIVATIVE_ID, count(*) AS Matches&#13;&#10;&#9;FROM dbo.MAKES INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.MODELS ON dbo.MAKES.MAKE_ID = dbo.MODELS.MAKE_ID INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.DERIVATIVES ON dbo.MODELS.MODEL_ID = dbo.DERIVATIVES.MODEL_ID INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.[VALUES] ON dbo.DERIVATIVES.DERIVATIVE_ID = dbo.[VALUES].DERIVATIVE_ID INNER JOIN&#13;&#10;&#9;&#9;&#9;&#9; dbo.ATTRIBUTES ON dbo.[VALUES].ATTRIBUTE_ID = dbo.ATTRIBUTES.ATTRIBUTE_ID&#13;&#10;&#9;WHERE ((ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID1 and (@VAL1 is null or VALUE = @VAL1)) or&#13;&#10;&#9;&#9; (ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID2 and (@VAL2 is null or VALUE = @VAL2)) or&#13;&#10;&#9;&#9; (ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID3 and (@VAL3 is null or VALUE = @VAL3)) or&#13;&#10;&#9;&#9; (ATTRIBUTES.ATTRIBUTE_ID = @ATT_ID4 and (@VAL4 is null or VALUE = @VAL4)) )&#13;&#10;&#9;GROUP BY dbo.DERIVATIVES.DERIVATIVE_ID&#13;&#10;&#9;HAVING count(*) >= CASE WHEN @VAL1 IS NOT NULL THEN 1 ELSE 0 END +&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; CASE WHEN @VAL2 IS NOT NULL THEN 1 ELSE 0 END +&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; CASE WHEN @VAL3 IS NOT NULL THEN 1 ELSE 0 END +&#13;&#10;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; CASE WHEN @VAL4 IS NOT NULL THEN 1 ELSE 0 END -2&#13;&#10;&#9;ORDER BY count(*) DESC&#13;&#10;">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="ATT_ID1" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="TextBox1" Name="VAL1" PropertyName="Text" />
<asp:Parameter Name="ATT_ID2" />
<asp:Parameter Name="VAL2" />
<asp:Parameter Name="ATT_ID3" />
<asp:Parameter Name="VAL3" />
<asp:Parameter Name="ATT_ID4" />
<asp:Parameter Name="VAL4" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DevConnectionString1 %>"
SelectCommand="SELECT * FROM [ATTRIBUTES]"></asp:SqlDataSource>
<br />
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
DataTextField="ATTRIBUTE_NAME" DataValueField="ATTRIBUTE_ID">
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox><br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="DERIVATIVE_ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="DERIVATIVE_ID" HeaderText="DERIVATIVE_ID" InsertVisible="False"
ReadOnly="True" SortExpression="DERIVATIVE_ID" />
<asp:BoundField DataField="Matches" HeaderText="Matches" ReadOnly="True" SortExpression="Matches" />
</Columns>
</asp:GridView>
</asp:Content>
 AFAIK I have configured the source to pick up the dropdownlist value and the textbox value (the text box is autopostback).
 Am i not submitting the data correctly? (It worked with a simple query...just not with this one). I have tried a stored procedure which works when testing just not when its live on a webpage.
 Please help!
 
(Visual Web Devleoper 2005 Express and SQL Server Management Studio Express)
 

View 4 Replies View Related

Working Query Refuses To Run In SQL Agent Job

Nov 16, 2007

Hi, I am in need of help,

I have a couple of queries that i run on my server but i need to automate them now. I have created a new job in the sql agent jobs and set up my steps accordingly.

My queries all run in a query window without trouble and they also parse in the command window of the sql agen job-step screen. When I run them manually, it fails with the first query moaning about my variables etc etc.


Is there some sort of limitation that i am not aware of or something?

View 4 Replies View Related

Formatting @query Results Using Xp_sendmail

Jul 20, 2005

I know formatting should be handled in the client app and not in SQL Serverbut this is the situation I must develop in so any help would beappreciated.I'm running the following in Query AnalyzerUSE PubsDECLARE @MessageSubject VARCHAR(50)SELECT @MessageSubject = 'Report'EXEC master.dbo.xp_sendmail 'me@mine.com',@query = 'SELECT au_fname, au_lname from pubs.dbo.authors',@subject = @MessageSubjectThe results in my email look like:au_fname au_lname------------------- ----------------------------------------Abraham BennetReginald Blotchet-HallsCheryl CarsonI would like the results to be like:First Name: AbrahamLast Name: BennetFirst Name: ReginaldLast Name: Blotchet-HallsFirst Name: CherylLast Name: CarsonThanks

View 2 Replies View Related

Server Refuses Connections!

Mar 20, 2000

S.O.S.

Today, my server began refusing connections for no apparent reason. I'm getting 2 different errors.
1. Server rejected the connection; Access to the selected database has been denied. (from one remote DSN)
2. Client unable to establish connection. (from another DSN)

It seems as if my server has lost it's mojo!!?? I have no clue as to why this is happening all of a sudden. Please help.

thanks,

Joe


Also, is there a better way I can trace my SQL Server ODBC errors (other than through Profiler)?

View 2 Replies View Related

DB Model Suspect. Server Refuses To Start

Jun 16, 2003

We have a SQL 7 server onboard a vessel, and it refuses to start. Errorlog says db model is suspect. Anyone know how to bring server up again ?

View 3 Replies View Related

DTS Fails Coes It Refuses To Fill The Unique Id Colum

Aug 16, 2007

THe unique Id column is set to identity seed. Yet when transfering 1500 records it fails to stuff them all becuase it says there is a NULL in unique id column.
"Cannot insert the value NULL into column UID column does not allow"
 Yet in the transformation screen I am setting the UID column to <ignore> meaning I do not have that value in my source and I am wanting the destination table to do it's thing and incrememnt by 1 the identity seed.
 Is this common?
THe source and destination tables are in the same databes.
 

View 4 Replies View Related

Modified Connection In Package Cionfiguration - Sql Server Agent Job Refuses To Run

Jun 18, 2007

Hello,



Here is the following mind-numbing problem I have (and wished I did not have to experience)



A set of 2 SSIS packages is scheduled to run in a sql server agent job on the same server. Both packages use an environment variable that point to a package configuration file. In this file there are 2 connections, one to a sql server with a sql server user id and passwordn, another to an AS400 DB2. Both packages are deployed on the same server in SSIS server under MSDB sql storage, with package protection level set to 'rely on server storage and roles for access control'.



Today the connection to the As400 needed to change, it is now connected to another AS400 server. The packages have been modified to use the new connection. In the configuration file the old connection has been commented out and the new connection string was added, the connection itself was given a new more meaningfull name in the packages.

Running the packages from visual studio 2005 works. After testing I have deployed the packages to SSIS server in MSDB storage.

Now when I start the sql server agent job that runs these packages, the job quits with an error, in the history I see an error message that it failed to connect to the sql server with the given sql server user account.

When I the step in the sql server agent job properties for both packages, under the Tab 'Data sources' I see that it is using the new AS400 connection. I can also see the connectionstring for the sql server with the user id (but no password).

To make it possible for my packages to run (the users are waiting for the data) I have solved it like this:

- under the 'configurations' tab I have added the name of my package configuration file.

- i did this for both packages in both job steps

when I run the job , it works without problems.



Now , my question is: I have hardcoded the pathname for the package configuration file in my job. Instead of the package using the environment variable to find th epackage configuration file. I would prefer my packages , when in a sql server agent job to also use the environment variable. What can I do to make this happen?



Flabbergasted as always,

View 6 Replies View Related

Jdbc Refuses Connection With 'user Not Associated With A Trusted SQL Server Connection' Message

Jul 10, 2007

When using jdbc with IntegratedSecurity, I run into this problem when the machine is not part of a domain & gets its IP address via dhcp. Is this expected behavior or a bug in the jdbc driver.



The SQLServer and client application are installed on the same machine and a local admin is logged in, running the client app.



If I change one of the two parameters mentioned above, the connection can be established leading me to believe this may be intentional for security issues. Am I correct?

View 6 Replies View Related

Snap Shot Agent Refuses To Snap New Articles.

Sep 7, 2005

Hi There

View 4 Replies View Related

Xp_sendmail

Jul 22, 2002

I am trying to use xp_sendmail with no luck. My SQL mail works fine and I am logged in as sa. Here is the csript that I am using. The script works on my local box(which is running Win 2K Advanced Server and SQL 7). It will not work on my production boxes. Any suggestions?

EXEC master..xp_sendmail
@recipients = 'Richard Peoples,
@message = 'Test',
@subject = 'Long-Running Job to Check'


Thanks!!!

View 2 Replies View Related

Xp_sendmail

Mar 27, 2001

Hi,

I am using xp_sendmail in a stored procedure.I need to update the fields after the mail sent. Is there a way to capture the errors or server messages that occurs. I am using the following code.....


select @myquery= 'Execute LeadDistribution..sp_sendmailB ' + convert(char,@AssToID) /*calling the sp_sendmailB procedure */

execute master.dbo.xp_sendmail @recipients='lakshmip@oasisnetwork.com', @message='Leads Information',@query=@myquery

Select @send_Mail=@@Error

If @send_Mail=0
Begin
update MasterleadPool/*Updates the MasterleadPool table once the mail sent */
Set EmailSent='Y', Dateout=getdate()
where AssToID=@AssToID and EmailSent='N' and AssToFlag='Y'
End


I used @@error to capture the error but it does'nt work. I got server message as follows.... So the problem is it should'nt go to update statement if there is any type of errors in sending a mail..

Server: Msg 17903, Level 18, State 1, Line 0
MAPI login failure.

(1 row(s) affected)

Please help me if anyone knows....

Thanks,
Sailaja

View 1 Replies View Related

Xp_sendmail

Dec 21, 2000

Greetings,

I am trying to utilize xp_sendmail passing a variable as the @recipients value.

EXEC master..xp_sendmail
@recipients = @EMAIL_ADDRESS_LNK,
etc.......

However in doing this, it never works (go figure or I wouldn't be submitting this). I have defined the variable @EMAIL_ADDRESS_LNK appropriately to reference a field in a table and I'm positive that the value in the field is valid.

What am I missing? If this is not possible, is there a workaround. Thanks in advance for any assistance you can provide.

View 7 Replies View Related

Xp_sendmail

Jan 9, 2001

Is there anyway to format the message text when using xp_sendmail ?? E.g. making some of it bold or in italics ??

View 1 Replies View Related

Xp_sendmail

Jan 18, 2001

I am using xp_sendmail in stored procedure and sending query using @query option. Is there a way to format the query output?

View 4 Replies View Related

Xp_sendmail

Feb 8, 2000

Hello,

How robust is xp_sendmail? I would like to roll thru 10 - 20 thousand records, strip the email and send a newsletter...

I'm a definite newby when it comes to mail servers (and how they interact with SQL Server 7.0)...so I'm not sure whether this type of processing would crash/stall the server.

can xp_sendmail handle this type of processing?

I appreciate your help,

p.s. can u point me to any good articles on the subject?

View 1 Replies View Related

Xp_sendmail

Mar 14, 2000

Hi
can the receiver list (xp_sendmail parameter) be a query. Becuase i must to concatenate. Thanks

View 1 Replies View Related

Xp_sendmail

Mar 6, 2003

I have a query that works on its own, however when I put
it into xp_sendmail it fails. It appears that the "set"
command does not work. Here is the query. Any suggestions?
Can you use variables within xp_sendmail @ query section?

EXEC master.dbo.xp_sendmail
@recipients = 'Richard Peoples',
@subject = 'The following Budget Checked items need
attention.',
@query ='DECLARE @A1 CHAR (20)
DECLARE @A2 CHAR (2)
SET @A1 = 'Yvette Palomo'
SET @A2 = 'N'
IF (select COUNT (*)
from FSPROD75.dbo.PS_C_JRNLLN_BUDCHK
where RETURN_TO_ANALYST = @A1 AND
BUDGET_CHECK_CLEAR= @A2) > 0
begin
select A.JOURNAL_ID, A.PROJECT_ID, A.ACCOUNT,
B.XLATLONGNAME from FSPROD75.dbo.PS_C_JRNLLN_BUDCHK A
INNER JOIN FSPROD75.dbo.XLATTABLE B ON A.BCM_LINE_STATUS =
B.FIELDVALUE
where (((A.RETURN_TO_ANALYST)= @A1) AND
((A.BUDGET_CHECK_CLEAR)=@A2)) AND (B.FIELDNAME
= "BCM_LINE_STATUS")
end'

View 1 Replies View Related

Xp_sendmail

May 15, 2003

i'm executing this statement:

exec xp_sendmail @recipients='[email add]', @message='hello'

and i get an error 0x80040111

what does that mean? what am i doing wrong?

i'm already using SQL Server authentication. it was working last week, but now it isn't.

help please

View 3 Replies View Related

Xp_sendmail

Jul 18, 2001

Is it possible to set the "From" address using the xp_sendmail procedure?

View 1 Replies View Related

Xp_sendmail

Jul 7, 2005

Dear Friends,

I need to configure SQL Server to send mails automatically. How to configure this?

Also what all are required for this? Is exchange server a must?

Hoping to get reply

Vipin

View 3 Replies View Related

Xp_sendmail

Jun 10, 2004

i'm trying to send email using sql server, but every time i try to run xp_sendmail i get this message:

xp_sendmail: failed with mail error 0x80040111


can anyone tell me what this error means???

View 3 Replies View Related

Xp_sendmail

Jun 23, 2004

Hi,

I want to use xp_sendmail like this

declare @user varchar
select @user = user
from users
where userid =1


exec.xp_sendmail @user, 'The master database is full.'



But I get an error message saying ambiguous recipient

Is there any way I cn do this?

View 5 Replies View Related

XP_Sendmail

Sep 22, 2004

I'm using XP_Sendmail on an NT Server and it works fine. We have a new Windows 2000 server, which the SQL Mail has been set up correctly, and the test passes.

When I use execute xp_sendmail in the query analyzer on the 2000 server, it just sits there and processes for over an hour, without any error messages.

Has anyone seen this before?

View 1 Replies View Related

Xp_sendmail

Dec 23, 2005

Hi All,

I have the following script that checks the amount of free space on the drive:

declare @MB_Free int

create table #FreeSpace(
Drive char(1),
MB_Free int)

insert into #FreeSpace exec xp_fixeddrives

select @MB_Free = MB_Free from #FreeSpace where Drive = 'J'


if @MB_Free < 550
exec master.dbo.xp_sendmail
@recipients = 'test@yahoo.com',
@message = 'Running low on free space'

I can run it as a job step. However, the problem is that we don't have Microsoft Outlook to run xp_sendmail proc to get notify when the free space on the drive is low. I can run mailsend which is os command and add that as a job step. But I don't know how to combine the code above and mailsend, since one is the t-sql and the other one is command script. Any help is appreciated.

View 5 Replies View Related

Xp_sendmail

Mar 11, 2004

I have recently added columns to a table that is part of a xp_send mail script. meaning i run a query off of the table that had the columns added. I am now getting the error:
failed with operating system error 32

I have no idea what this means. This is a copy of the script.
exec xp_sendmail 'dionne, jim;eddens, david;Wiggs, Alexander;Miller, Debbie;conmdi', '(scrbbususcnc01) Failure 322 Load', @Attachments = '322Error.txt;\scrbbususcnc01archive322msg322M SG.txt;', @query = 'Use [maersk data warehouse]
create table #Duplicate_Records (Equipment_Number varchar(10)
,Activity_Date varchar(6)
,Activity_Time varchar(4)
,Sighting_Code varchar(2)
,CountOfEquipment_Number int)
insert into #Duplicate_Records
SELECT STG_INTERMODAL_322MSG_TBL.Equipment_Number,
STG_INTERMODAL_322MSG_TBL.Activity_Date,
STG_INTERMODAL_322MSG_TBL.Activity_Time,
STG_INTERMODAL_322MSG_TBL.Sighting_Code,
Count(STG_INTERMODAL_322MSG_TBL.Equipment_Number) AS CountOfEquipment_Number
FROM STG_INTERMODAL_322MSG_TBL
GROUP BY STG_INTERMODAL_322MSG_TBL.Equipment_Number,
STG_INTERMODAL_322MSG_TBL.Activity_Date,
STG_INTERMODAL_322MSG_TBL.Activity_Time,
STG_INTERMODAL_322MSG_TBL.Sighting_Code
HAVING (((Count(STG_INTERMODAL_322MSG_TBL.Equipment_Numbe r))>1))

create table #None ([Equipment_Number] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Equip_Nbr_11_Digit] [varchar] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Activity_Date] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Activity_Time] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Sighting_Code] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[filler] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Location_City] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Location_State] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Status] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Train_Junction] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Send_Date] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Send_Time] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Road] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Destination_City] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Destination_State] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Source] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Flag] [varchar] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Flatcar_Number] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Chassis_Number] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Work_Order_Number] [varchar] (13) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[BKG_BL_Number] [varchar] (9) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Train_ID] [varchar] (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Last_Free_Date] [varchar] (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Process_Date] [datetime] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[splc_code] varchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS null,
[Origin_SPLC] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Operator] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Shpt_Type] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Pickup_Number] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL )

insert into #None
SELECT DISTINCT STG_INTERMODAL_322MSG_TBL.*
FROM [#Duplicate_Records] INNER JOIN STG_INTERMODAL_322MSG_TBL ON ([#Duplicate_Records].Sighting_Code = STG_INTERMODAL_322MSG_TBL.Sighting_Code) AND ([#Duplicate_Records].Activity_Time = STG_INTERMODAL_322MSG_TBL.Activity_Time) AND ([#Duplicate_Records].Activity_Date = STG_INTERMODAL_322MSG_TBL.Activity_Date) AND ([#Duplicate_Records].Equipment_Number = STG_INTERMODAL_322MSG_TBL.Equipment_Number)
ORDER BY STG_INTERMODAL_322MSG_TBL.Equipment_Number, STG_INTERMODAL_322MSG_TBL.Activity_Date, STG_INTERMODAL_322MSG_TBL.Activity_Time, STG_INTERMODAL_322MSG_TBL.Sighting_Code;


create table #Real (Equipment_Number varchar(10)
,Activity_Date varchar(6)
,Activity_Time varchar(4)
,Sighting_Code varchar(2)
,CountOfEquipment_Number int)
insert into #Real
SELECT [#None].Equipment_Number,
[#None].Activity_Date,
[#None].Activity_Time,
[#None].Sighting_Code,
Count([#None].Equipment_Number) AS CountOfEquipment_Number
FROM [#None]
GROUP BY [#None].Equipment_Number, [#None].Activity_Date, [#None].Activity_Time, [#None].Sighting_Code
HAVING (((Count([#None].Equipment_Number))>1));


SELECT STG_INTERMODAL_322MSG_TBL.*
FROM [#Real] INNER JOIN STG_INTERMODAL_322MSG_TBL ON ([#Real].Equipment_Number = STG_INTERMODAL_322MSG_TBL.Equipment_Number) AND ([#Real].Activity_Date = STG_INTERMODAL_322MSG_TBL.Activity_Date) AND ([#Real].Activity_Time = STG_INTERMODAL_322MSG_TBL.Activity_Time) AND ([#Real].Sighting_Code = STG_INTERMODAL_322MSG_TBL.Sighting_Code)
ORDER BY STG_INTERMODAL_322MSG_TBL.Equipment_Number, STG_INTERMODAL_322MSG_TBL.Activity_Date, STG_INTERMODAL_322MSG_TBL.Activity_Time, STG_INTERMODAL_322MSG_TBL.Sighting_Code;


drop table #Duplicate_Records
drop table #None
drop table #Real', @subject = '(scrbbususcnc01) Failure 322 Load' , @Attach_Results = true, @width = 3000, @Separator = '|'



any thoughts would be great.
Jim

View 2 Replies View Related

Xp_sendmail

Mar 31, 2004

I am trying to send a resultset via email using xp_sendmail.
I need to send the email when an earlier executed query has any results.

Got the query results into a table variable/temp table and then
in xp_sendmail, using

"Declare @table_var table(...)

..query excution..

EXEC master.dbo.xp_sendmail @recipients = 'xx@xx.com',
@query = 'select * from @table_var'"

it gives error saying that @table_var must be declared.
even if i use temporary table, the message i get is "cannot reference object in tempdb database."

any ideas on this.

Thanks in advance.

View 2 Replies View Related

XP_Sendmail Help

Jun 19, 2008

Hello,

I want to send a reslut as a xls file. so I did it throug BCP. The same time i need to send file in mail. Here i am stucked. Could any one please advise me to solve this problem?

Declare @date varchar(100), @SqlBcp Varchar(1000)
Select @date = Convert( varchar, getdate(),112)+Replace (Convert(varchar, Getdate(),114),':','')
Set @SqlBcp = 'Master..Xp_CmdShell '+'''bcp "Select * from KK_TEST..JobStatus" queryout "C: esting'+@date+'.xls" -c -T'''

EXEC master.dbo.xp_sendmail
@recipients = N'xxxx@xxxxxxxxx.com',
@query = N'Exec ('+ @SqlBcp +')',
@subject = N'Failed Job Details',
@message = N'The contents of JobStatus ',
@attach_results = 'TRUE',
@width = 250 ;


Thanks
Krishna

View 2 Replies View Related

Xp_sendmail

Jul 20, 2005

when creating a sp in SQL 2K that uses xp_sendmail i get a messagesaying:Cannot add rows to sysdepends for the current stored procedure becauseit depends on the missing object 'xp_sendmail'. The stored procedurewill still be created.does this mean that only dependencies involving xp_sendmail will notbe stored? the other dependencies appear to be fine. i'm not surewhy sql would even bother telling me this info. thoughts?

View 1 Replies View Related

Xp_sendmail

Jan 28, 2008

I am having a problem sending an email using the stored procedure "xp_sendmail".
This query is good.


SELECT h.order_id, h.order_date, h.responsible2 as "requested by", sum(d.cur_amount) as amount

FROM table1 as h inner join table2 as d

on h.order_id = d.order_id

where h.accept_flag = 0

and h.order_date > ' jan 1 2006 '

GROUP BY h.order_id,h.order_date, h.responsible2

ORDER BY h.order_id


The same query used to send an email does not work, don't know why.



master.dbo.xp_sendmail 'email@domainname.com,

@subject= 'POs that need approval',

@dbuse= 'database',

@query = '

SELECT h.order_id, h.order_date, h.responsible2 as "requested by", sum(d.cur_amount) as amount

FROM table1 as h inner join table2 as d

on h.order_id = d.order_id

where h.accept_flag = 0

and h.order_date > ' jan 1 2006 '

GROUP BY h.order_id,h.order_date, h.responsible2

ORDER BY h.order_id

'

Here is the error msg


Msg 170, Level 15, State 1, Line 10

Line 10: Incorrect syntax near 'jan'.

Any help would be appreciated!

View 4 Replies View Related

Xp_sendmail

Nov 23, 2007

I migrated dts pckg into ssis . In that pckg i have one activex script for xp_sendmail.
exec maseter xp_sendmail,
@recipients='abc@gmail.com',
@query=@sqlsrd,
@subject='member load validation',
@attach_results=true,@width=250

above code run in ssis or i have to change if i have to chang then tell me where should i have to change.


Thanks
Aric

View 5 Replies View Related

Xp_sendmail

Apr 16, 2008



I am trying to use xp_sendmail with operator instead email id.

it is not taking operator

is there anyway to use operator with xp_sendmail

I have valid operator it is working with jobs

Thanks
Gan

View 3 Replies View Related

Xp_sendmail

Oct 1, 2006

Ok all...I'm not having much luck with this.

I'm using SQL Server 2005 MSE

I try to run

xp_sendmail 'adam@getpaid4spam.biz', 'This is a test'

And I get the following error...

Msg 17750, Level 16, State 0, Procedure xp_sendmail, Line 1

Could not load the DLL sqlmap90.dll, or one of the DLLs it references. Reason: 126(The specified module could not be found.).

Any ideas?

Adamus

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved