<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Contact Me</title>
	<atom:link href="http://blog.sqlauthority.com/contact-me-contact-pinaldave/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: deep</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57772</link>
		<dc:creator>deep</dc:creator>
		<pubDate>Fri, 20 Nov 2009 11:17:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57772</guid>
		<description>hi pinal,

please give same way to tuning a SP.</description>
		<content:encoded><![CDATA[<p>hi pinal,</p>
<p>please give same way to tuning a SP.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amitabh Bachan.</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57756</link>
		<dc:creator>Amitabh Bachan.</dc:creator>
		<pubDate>Fri, 20 Nov 2009 03:57:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57756</guid>
		<description>Okay, I did this but I was able to inject (both delete and drop table statement worked.). Can you please a solution on sp_executesql. Yes, I did LOTS OF GOOGLE FOR PAST 8 HOURS WITH NO LUCK... THANKS

CREATE PROCEDURE uspGetEmployee
@LastName VARCHAR(50) = NULL
AS
BEGIN
SET NOCOUNT ON;
DECLARE @sql NVARCHAR(300)        
SELECT @sql = &#039; SELECT * &#039; + &#039; FROM EMPLOYEES 
			WHERE 1=1 &#039;
IF @LastName	IS NOT NULL
	SELECT @sql = @sql + &#039; AND [LASTNAME] = @LastName&#039;
EXEC sp_executesql @sql, N&#039;@lastname VARCHAR(50)&#039;, @LastName
end
GO

Here is how I deleted and drop the table...

DECLARE @RC int
DECLARE @LastName varchar(50)
EXECUTE @RC = [Northwind].[dbo].[uspGetEmployee] 
   delete from employees where lastname=&#039;king&#039;</description>
		<content:encoded><![CDATA[<p>Okay, I did this but I was able to inject (both delete and drop table statement worked.). Can you please a solution on sp_executesql. Yes, I did LOTS OF GOOGLE FOR PAST 8 HOURS WITH NO LUCK&#8230; THANKS</p>
<p>CREATE PROCEDURE uspGetEmployee<br />
@LastName VARCHAR(50) = NULL<br />
AS<br />
BEGIN<br />
SET NOCOUNT ON;<br />
DECLARE @sql NVARCHAR(300)<br />
SELECT @sql = &#8216; SELECT * &#8216; + &#8216; FROM EMPLOYEES<br />
			WHERE 1=1 &#8216;<br />
IF @LastName	IS NOT NULL<br />
	SELECT @sql = @sql + &#8216; AND [LASTNAME] = @LastName&#8217;<br />
EXEC sp_executesql @sql, N&#8217;@lastname VARCHAR(50)&#8217;, @LastName<br />
end<br />
GO</p>
<p>Here is how I deleted and drop the table&#8230;</p>
<p>DECLARE @RC int<br />
DECLARE @LastName varchar(50)<br />
EXECUTE @RC = [Northwind].[dbo].[uspGetEmployee]<br />
   delete from employees where lastname=&#8217;king&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pravin</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57733</link>
		<dc:creator>Pravin</dc:creator>
		<pubDate>Thu, 19 Nov 2009 10:56:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57733</guid>
		<description>Hi,

Need some help regarding SQL server 2005 .

I have set up replication on SQL server 2005 with tables and Clustered and non clustered indexes being replicated.

What i want to know here is what are the important parameters to be monitored and how to set up Notification alerts for the monitoring of these parameters or failures .

Thanks 

Pravin</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Need some help regarding SQL server 2005 .</p>
<p>I have set up replication on SQL server 2005 with tables and Clustered and non clustered indexes being replicated.</p>
<p>What i want to know here is what are the important parameters to be monitored and how to set up Notification alerts for the monitoring of these parameters or failures .</p>
<p>Thanks </p>
<p>Pravin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajesh G</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57732</link>
		<dc:creator>Rajesh G</dc:creator>
		<pubDate>Thu, 19 Nov 2009 09:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57732</guid>
		<description>hello Pinal,

Im a web site developer, I have a question for you. currently my team is busy doing database optimization task. I was asked to sort out the SPs and it full statics. I was able to do the thing except the condition, which is very challenging.
We r using sql server 2005(Without sp2).
My Query is that i have to sort out all the SPs which was never used, at this moment im able to get list with the help of sys.dm_exec_cached_plans but its giving the list which was executed at least once, furthermore there is no relation between the rows returned by sys.dm_exec_cached_plans and sys.object so that I can get SP name and its execution_count in a single query.

Please suggest help...
Thanks in advance.</description>
		<content:encoded><![CDATA[<p>hello Pinal,</p>
<p>Im a web site developer, I have a question for you. currently my team is busy doing database optimization task. I was asked to sort out the SPs and it full statics. I was able to do the thing except the condition, which is very challenging.<br />
We r using sql server 2005(Without sp2).<br />
My Query is that i have to sort out all the SPs which was never used, at this moment im able to get list with the help of sys.dm_exec_cached_plans but its giving the list which was executed at least once, furthermore there is no relation between the rows returned by sys.dm_exec_cached_plans and sys.object so that I can get SP name and its execution_count in a single query.</p>
<p>Please suggest help&#8230;<br />
Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benji</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57730</link>
		<dc:creator>Benji</dc:creator>
		<pubDate>Thu, 19 Nov 2009 08:53:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57730</guid>
		<description>Hi Pinalkumar,

I have a concern regarding Stored Procedure &amp; Execution Plan Cache. 
I&#039;ve heard that it&#039;s not good when the execution logic depends too much on the input parameters, wrong execution plan maybe chosen and causes bad performance. However I have a scenarios like this: I have 3 task to do: Update, Insert, Select. And I have 2 way to create SPs

1. Create 1 SP only, with an input parameter to tell which action need doing, something like:
if &#039;U&#039; then update data 
if &#039;I&#039; then insert data
.......
2. Create 3 separate SPs for those 3 actions.

For not too complicated SPs, I like option 2, to reduce the number of SPs. However, which is better regarding performance on large databases?

Thank you very much,</description>
		<content:encoded><![CDATA[<p>Hi Pinalkumar,</p>
<p>I have a concern regarding Stored Procedure &amp; Execution Plan Cache.<br />
I&#8217;ve heard that it&#8217;s not good when the execution logic depends too much on the input parameters, wrong execution plan maybe chosen and causes bad performance. However I have a scenarios like this: I have 3 task to do: Update, Insert, Select. And I have 2 way to create SPs</p>
<p>1. Create 1 SP only, with an input parameter to tell which action need doing, something like:<br />
if &#8216;U&#8217; then update data<br />
if &#8216;I&#8217; then insert data<br />
&#8230;&#8230;.<br />
2. Create 3 separate SPs for those 3 actions.</p>
<p>For not too complicated SPs, I like option 2, to reduce the number of SPs. However, which is better regarding performance on large databases?</p>
<p>Thank you very much,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pradeep</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57686</link>
		<dc:creator>pradeep</dc:creator>
		<pubDate>Wed, 18 Nov 2009 05:50:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57686</guid>
		<description>Hi Friends,

Could any body help me to find out SQL serevr BI tutorials in Mumbai?



Thanks,</description>
		<content:encoded><![CDATA[<p>Hi Friends,</p>
<p>Could any body help me to find out SQL serevr BI tutorials in Mumbai?</p>
<p>Thanks,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pragnesh</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57671</link>
		<dc:creator>pragnesh</dc:creator>
		<pubDate>Tue, 17 Nov 2009 14:54:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57671</guid>
		<description>hi pinal,
i was looking for Reporting Services at your blog but no luck.
Please can you suggest some good reference to SQL Reporting services? or 
Can you post something related to reporting services?

Thanks</description>
		<content:encoded><![CDATA[<p>hi pinal,<br />
i was looking for Reporting Services at your blog but no luck.<br />
Please can you suggest some good reference to SQL Reporting services? or<br />
Can you post something related to reporting services?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deepak</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57658</link>
		<dc:creator>deepak</dc:creator>
		<pubDate>Tue, 17 Nov 2009 07:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57658</guid>
		<description>Thanks in advance brother..</description>
		<content:encoded><![CDATA[<p>Thanks in advance brother..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deepak</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57657</link>
		<dc:creator>deepak</dc:creator>
		<pubDate>Tue, 17 Nov 2009 07:39:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57657</guid>
		<description>We have one production DB. We are copying data from production ,say X….and archive DB , say Y, to one more DB , say Z….which is specially used for reporting.
  
Our reports will always point to reporting DB Y….and every day there is reconsolidation of data for each process like orders, lens etc into respective tables in reporting DB.
Reconsolidation scripts will use the ARCHIVE DB Y.

Now archive DB Y. size is very large so customer decided to split the DB into year wise DB’s…

Like
•           Y.__ARCHIVE_2009
•           Y.__ARCHIVE_2008
•           Y.__ARCHIVE_2007

If we do this change,we have to run consolidation scripts on every above DB’s…now its 2009 but in future 2020, we have to run scripts in 10 to 20 Archive DB’s..

My question: Is it right way to handle this kind of satuation? If not, what is the best approch?</description>
		<content:encoded><![CDATA[<p>We have one production DB. We are copying data from production ,say X….and archive DB , say Y, to one more DB , say Z….which is specially used for reporting.</p>
<p>Our reports will always point to reporting DB Y….and every day there is reconsolidation of data for each process like orders, lens etc into respective tables in reporting DB.<br />
Reconsolidation scripts will use the ARCHIVE DB Y.</p>
<p>Now archive DB Y. size is very large so customer decided to split the DB into year wise DB’s…</p>
<p>Like<br />
•           Y.__ARCHIVE_2009<br />
•           Y.__ARCHIVE_2008<br />
•           Y.__ARCHIVE_2007</p>
<p>If we do this change,we have to run consolidation scripts on every above DB’s…now its 2009 but in future 2020, we have to run scripts in 10 to 20 Archive DB’s..</p>
<p>My question: Is it right way to handle this kind of satuation? If not, what is the best approch?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo Alonso</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57652</link>
		<dc:creator>Pablo Alonso</dc:creator>
		<pubDate>Mon, 16 Nov 2009 20:33:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57652</guid>
		<description>Hi Pinal, I have a question for ms sql 2000 that you maybe can help me.

I&#039;m not a dba, I was just needing to do a &quot;what I thought was a sinple task&quot; and suddenly I meet hell.

What I need to do is as simple as to duplicate a database with a different name and I have no found a procedure to complete this task successfully.

I have seen this http://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/ and this http://www.mssqltips.com/tip.asp?tip=1122 with no results. always the data file keeps having same name and I cannot mount both databases at the same time in same server.

What I need is... simply a database called PRODUCTION copy this same entire database to same ms sql server 2000 with other name like TESTDB.

If you have a way of doing this please contact me!

Thank you very much.

Regards,
Pablo Alonso</description>
		<content:encoded><![CDATA[<p>Hi Pinal, I have a question for ms sql 2000 that you maybe can help me.</p>
<p>I&#8217;m not a dba, I was just needing to do a &#8220;what I thought was a sinple task&#8221; and suddenly I meet hell.</p>
<p>What I need to do is as simple as to duplicate a database with a different name and I have no found a procedure to complete this task successfully.</p>
<p>I have seen this <a href="http://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/" rel="nofollow">http://blog.sqlauthority.com/2007/07/13/sql-server-2005-use-alter-database-modify-name-instead-of-sp_renamedb-to-rename/</a> and this <a href="http://www.mssqltips.com/tip.asp?tip=1122" rel="nofollow">http://www.mssqltips.com/tip.asp?tip=1122</a> with no results. always the data file keeps having same name and I cannot mount both databases at the same time in same server.</p>
<p>What I need is&#8230; simply a database called PRODUCTION copy this same entire database to same ms sql server 2000 with other name like TESTDB.</p>
<p>If you have a way of doing this please contact me!</p>
<p>Thank you very much.</p>
<p>Regards,<br />
Pablo Alonso</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clayton Hoyt</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57647</link>
		<dc:creator>Clayton Hoyt</dc:creator>
		<pubDate>Mon, 16 Nov 2009 16:46:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57647</guid>
		<description>Hi Pinal,

I am working on a process flow application and within a group of records, I need to create subgroups based upon certain actions.

As the process moves from one person to the next, the current user can reject the process, causing it to move back to the beginning again. The first time the process goes through would be subgroup 1. If it gets rejected, the next group will be subgroup 2. Going forward, this would be pretty easy if I could change the table structure and add a new column. Unfortunately, that is not possible. This will have to be a dynamic process.

I know I could do this with a cursor or other looping structure but would rather use CTE.

Can you give me any thoughts on how to accomplish this?

Thanks!

Clay</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I am working on a process flow application and within a group of records, I need to create subgroups based upon certain actions.</p>
<p>As the process moves from one person to the next, the current user can reject the process, causing it to move back to the beginning again. The first time the process goes through would be subgroup 1. If it gets rejected, the next group will be subgroup 2. Going forward, this would be pretty easy if I could change the table structure and add a new column. Unfortunately, that is not possible. This will have to be a dynamic process.</p>
<p>I know I could do this with a cursor or other looping structure but would rather use CTE.</p>
<p>Can you give me any thoughts on how to accomplish this?</p>
<p>Thanks!</p>
<p>Clay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anil kumar dubey</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57642</link>
		<dc:creator>Anil kumar dubey</dc:creator>
		<pubDate>Mon, 16 Nov 2009 13:40:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57642</guid>
		<description>Hi,

Give me few most promising reason when we are left with no option and have to use cursor only instead of while loop.


Thanks

Anil</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Give me few most promising reason when we are left with no option and have to use cursor only instead of while loop.</p>
<p>Thanks</p>
<p>Anil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tarun</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57582</link>
		<dc:creator>Tarun</dc:creator>
		<pubDate>Fri, 13 Nov 2009 06:18:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57582</guid>
		<description>Hi Pinal,

I have created 2 schemas in one database and trying to run the script in order to create tables under schemas. but problem is that script has another schema inside it and when i run that script its giving me error like:
”
User does not have permission to perform this action.
Msg 2759, Level 16, State 0, Line 2
CREATE SCHEMA failed due to previous errors.”

E.g

I have 2 schemas say Tarun1,Tarun2 under abc database. now I want to add some table under Tarun1, Tarun2 schema. (something like nested schemas... )

Here is script:
– Create schema for common tables
create schema OLS_TABLES
;

– Create common tables
create table OLS_TABLES.Table1(
ID nvarchar(20) not null,
TYPE nvarchar(50) not null,
SCRIPT varbinary(max),
primary key(ID, TYPE)
)
;

Can we add OLS_TABLES schema under Tarun1 schema? If yes then please suggest me how we can do that? what Kind of permissions we need?

Waiting for your reply!
Thanks in advance

Tarun</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I have created 2 schemas in one database and trying to run the script in order to create tables under schemas. but problem is that script has another schema inside it and when i run that script its giving me error like:<br />
”<br />
User does not have permission to perform this action.<br />
Msg 2759, Level 16, State 0, Line 2<br />
CREATE SCHEMA failed due to previous errors.”</p>
<p>E.g</p>
<p>I have 2 schemas say Tarun1,Tarun2 under abc database. now I want to add some table under Tarun1, Tarun2 schema. (something like nested schemas&#8230; )</p>
<p>Here is script:<br />
– Create schema for common tables<br />
create schema OLS_TABLES<br />
;</p>
<p>– Create common tables<br />
create table OLS_TABLES.Table1(<br />
ID nvarchar(20) not null,<br />
TYPE nvarchar(50) not null,<br />
SCRIPT varbinary(max),<br />
primary key(ID, TYPE)<br />
)<br />
;</p>
<p>Can we add OLS_TABLES schema under Tarun1 schema? If yes then please suggest me how we can do that? what Kind of permissions we need?</p>
<p>Waiting for your reply!<br />
Thanks in advance</p>
<p>Tarun</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krishna Mohan</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57578</link>
		<dc:creator>Krishna Mohan</dc:creator>
		<pubDate>Fri, 13 Nov 2009 04:29:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57578</guid>
		<description>Hi Imran Mohammed,

Thanks for yours reply.

exec PRJ_SP_Project_PMT_Notify

Note : first give spiProject login account permission for mater database.

Use Mater
grant execute on xp_smtp_sendmail to spiProject

use master
go
Grant Execute on xp_smtp_sendmail to [Job_Owner]
go 

I done all the settings , no luck and also insted on xp_smtp_sendmail  i used msdb.dbo.sp_send_dbmail.

I done all the Configuration for sp_send_dbmail. Through SP mails going same thing i execute from job same error coming. 

Using Database Mail with SQL Server Agent
http://msdn.microsoft.com/en-us/library/ms190606.aspx

above settings also i done. Why emails are not triggering from jobs through storeprocedures its triggering mails.</description>
		<content:encoded><![CDATA[<p>Hi Imran Mohammed,</p>
<p>Thanks for yours reply.</p>
<p>exec PRJ_SP_Project_PMT_Notify</p>
<p>Note : first give spiProject login account permission for mater database.</p>
<p>Use Mater<br />
grant execute on xp_smtp_sendmail to spiProject</p>
<p>use master<br />
go<br />
Grant Execute on xp_smtp_sendmail to [Job_Owner]<br />
go </p>
<p>I done all the settings , no luck and also insted on xp_smtp_sendmail  i used msdb.dbo.sp_send_dbmail.</p>
<p>I done all the Configuration for sp_send_dbmail. Through SP mails going same thing i execute from job same error coming. </p>
<p>Using Database Mail with SQL Server Agent<br />
<a href="http://msdn.microsoft.com/en-us/library/ms190606.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms190606.aspx</a></p>
<p>above settings also i done. Why emails are not triggering from jobs through storeprocedures its triggering mails.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57572</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Fri, 13 Nov 2009 01:34:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57572</guid>
		<description>@Anil

create table #example1 ( ID int, StartDate datetime, EndDate datetime)
insert into #example1 values ( 1, &#039;10/10/2009&#039;, &#039;10/30/2009&#039;)
insert into #example1 values ( 2, &#039;10/15/2009&#039;, &#039;11/20/2009&#039;)
insert into #example1 values ( 3, &#039;11/10/2009&#039;, &#039;12/31/2009&#039;)
insert into #example1 values ( 4, &#039;09/01/2009&#039;, &#039;10/25/2009&#039;)

select	ID, StartDate,EndDate
From	#example1
Where	EndDate = (select Max(EndDate)from #example1)
go 
drop table #Example1

~ IM.</description>
		<content:encoded><![CDATA[<p>@Anil</p>
<p>create table #example1 ( ID int, StartDate datetime, EndDate datetime)<br />
insert into #example1 values ( 1, &#8216;10/10/2009&#8242;, &#8216;10/30/2009&#8242;)<br />
insert into #example1 values ( 2, &#8216;10/15/2009&#8242;, &#8216;11/20/2009&#8242;)<br />
insert into #example1 values ( 3, &#8216;11/10/2009&#8242;, &#8216;12/31/2009&#8242;)<br />
insert into #example1 values ( 4, &#8216;09/01/2009&#8242;, &#8216;10/25/2009&#8242;)</p>
<p>select	ID, StartDate,EndDate<br />
From	#example1<br />
Where	EndDate = (select Max(EndDate)from #example1)<br />
go<br />
drop table #Example1</p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57570</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Fri, 13 Nov 2009 01:22:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57570</guid>
		<description>@Krishna Mohan

To answer your question quickly, You said, you put that script in a job and execute job and it fails, 
Solution: Give the owner of the job execute permission to stored procedure : xp_smtp_sendmail in master database. Below is a sample script.

use master
go
Grant Execute on xp_smtp_sendmail  to [Job_Owner]
go 

Question: 
Dude, did you said, you are on SQL Server 2008, why are you still using xp_smtp_sendmail stored procedure, this is not a native SQL Server stored procedure, this is a third party stored procedure. 

Instead of this you can use, SQL Server native stored procedure with same functionality as xp_smtp_sendmail, this procedure is available from SQL Server 2005 and higher version.

Stored Procedure Name: msdb.dbo.sp_send_dbmail

Let us know, if you need more help with your migration.

~ IM.</description>
		<content:encoded><![CDATA[<p>@Krishna Mohan</p>
<p>To answer your question quickly, You said, you put that script in a job and execute job and it fails,<br />
Solution: Give the owner of the job execute permission to stored procedure : xp_smtp_sendmail in master database. Below is a sample script.</p>
<p>use master<br />
go<br />
Grant Execute on xp_smtp_sendmail  to [Job_Owner]<br />
go </p>
<p>Question:<br />
Dude, did you said, you are on SQL Server 2008, why are you still using xp_smtp_sendmail stored procedure, this is not a native SQL Server stored procedure, this is a third party stored procedure. </p>
<p>Instead of this you can use, SQL Server native stored procedure with same functionality as xp_smtp_sendmail, this procedure is available from SQL Server 2005 and higher version.</p>
<p>Stored Procedure Name: msdb.dbo.sp_send_dbmail</p>
<p>Let us know, if you need more help with your migration.</p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Imran Mohammed</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57568</link>
		<dc:creator>Imran Mohammed</dc:creator>
		<pubDate>Fri, 13 Nov 2009 00:57:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57568</guid>
		<description>@Frida,

Can you provide more details, why you do not want to use Management Studio. 

Do you want a Stored Procedure, which you can call from (Front End) application to add a user ......

If you want a Stored Procedure, then yes, it could be done. 

~ IM.</description>
		<content:encoded><![CDATA[<p>@Frida,</p>
<p>Can you provide more details, why you do not want to use Management Studio. </p>
<p>Do you want a Stored Procedure, which you can call from (Front End) application to add a user &#8230;&#8230;</p>
<p>If you want a Stored Procedure, then yes, it could be done. </p>
<p>~ IM.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57552</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Thu, 12 Nov 2009 14:16:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57552</guid>
		<description>@Anil

Is this what you want?

SELECT TOP(1) ID, Startdate, endDate FROM mytab ORDER BY endDate DESC;</description>
		<content:encoded><![CDATA[<p>@Anil</p>
<p>Is this what you want?</p>
<p>SELECT TOP(1) ID, Startdate, endDate FROM mytab ORDER BY endDate DESC;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frida</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57545</link>
		<dc:creator>Frida</dc:creator>
		<pubDate>Thu, 12 Nov 2009 09:53:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57545</guid>
		<description>Hi, 
i want a query that add an existed user login to specific databases with a specified role (db_datareader) and not using management studio to add a user to a role for every database. Is there a way to do that?

Thank you in advance.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
i want a query that add an existed user login to specific databases with a specified role (db_datareader) and not using management studio to add a user to a role for every database. Is there a way to do that?</p>
<p>Thank you in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krishna Mohan</title>
		<link>http://blog.sqlauthority.com/contact-me-contact-pinaldave/#comment-57538</link>
		<dc:creator>Krishna Mohan</dc:creator>
		<pubDate>Thu, 12 Nov 2009 05:54:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?page_id=6010#comment-57538</guid>
		<description>Hi,

We are using  master.dbo.xp_smtp_sendmail  .      

EXEC master.dbo.xp_smtp_sendmail         
 @from = N&#039;spiProjectqmail@spi.com&#039;,                
        @TO = @Recipients_Id,         
        @message = @strMessage,                 
     @type = N&#039;text/html&#039;,                  
        @subject = @strSubject,                 
        @server = N &#039;IP address&#039;    

TestSP contains above staements and also its working fine in SQL Server 2008 Query Editor but same TestSP we created Job and run that job its giving error.
Message
Executed as user: dbo. The EXECUTE permission was denied on the object &#039;xp_smtp_sendmail&#039;, database &#039;master&#039;, schema &#039;dbo&#039;. [SQLSTATE 42000] (Error 229).  NOTE: The step was retried the requested number of times (1) without succeeding.  The step failed.


Any Configuration Required for xp_smtp_sendmail  to run from SQL Agent.

Can you please help me, this week end production migration.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>We are using  master.dbo.xp_smtp_sendmail  .      </p>
<p>EXEC master.dbo.xp_smtp_sendmail<br />
 @from = N&#8217;spiProjectqmail@spi.com&#8217;,<br />
        @TO = @Recipients_Id,<br />
        @message = @strMessage,<br />
     @type = N&#8217;text/html&#8217;,<br />
        @subject = @strSubject,<br />
        @server = N &#8216;IP address&#8217;    </p>
<p>TestSP contains above staements and also its working fine in SQL Server 2008 Query Editor but same TestSP we created Job and run that job its giving error.<br />
Message<br />
Executed as user: dbo. The EXECUTE permission was denied on the object &#8216;xp_smtp_sendmail&#8217;, database &#8216;master&#8217;, schema &#8216;dbo&#8217;. [SQLSTATE 42000] (Error 229).  NOTE: The step was retried the requested number of times (1) without succeeding.  The step failed.</p>
<p>Any Configuration Required for xp_smtp_sendmail  to run from SQL Agent.</p>
<p>Can you please help me, this week end production migration.</p>
]]></content:encoded>
	</item>
</channel>
</rss>