Showing posts with label proc. Show all posts
Showing posts with label proc. Show all posts

Tuesday, March 20, 2012

Can't see stored proc results

I have this stored proc:

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[usp_CrimRecTest]
-- Add the parameters for the stored procedure here
@.caseID [nvarchar]

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT dbo.tblCASENOMASTER.CASENO, dbo.tblCASEMAST.LASTNAME, dbo.tblCASEMAST.FRSTNAME
FROM dbo.tblCASENOMASTER LEFT OUTER JOIN
dbo.tblCASEMAST ON dbo.tblCASENOMASTER.CASENO = dbo.tblCASEMAST.CASENO
WHERE (dbo.tblCASENOMASTER.CASENO = @.caseID)
END

When I run this with an EXEC statement, the result pane shows no results but the message pane says it completed successfully and one row is affected. I know my input data is good. I also get nothing when I call this sproc from a VB front end. Any ideas?

Thanks.

What did you mean by --Insert statements for procedure here ? Is there something which you commented out for posting here ? The insert can prdouce x rows affected also as the Select part can. So the insert suceeded with X rows, but the query didn′t bring back any results.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de
|||All comment lines in this post are from the template produced when I created the sproc in SQL Server 2005. The code posted is copied directly from my sproc - nothing deleted, altered or commented out.|||

I found the problem.

@.caseID [nvarchar] was changed to:

@.caseID nvarchar(12)

This ran correctly.

Thanks for your reply Jens.

Monday, March 19, 2012

Can't run Stored Procedure

I am trying to run a stored procedure from an SQL task:

First, here is the proc (execs fine in : SSMS query)

CREATE PROC [dbo].[sp_Hist_Max_Dates]

@.Interval varchar(8),

@.Name1 varchar(32),

@.Max_Date datetime OUTPUT

AS

IF @.Interval = 'd'

BEGIN

SELECT @.Max_Date = MAX(Max_Daily_Date) FROM SiteTable WHERE Site_Name = @.Name1

END

ELSE IF @.Interval = 'm'

BEGIN

SELECT @.Max_Date = MAX(Max_Monthly_Date) FROM SIteTable WHERE SIte_Name = @.Name1

END

Here is the call from the Execute SQL Task:

EXEC sp_Hist_Max_Dates ?, ?, ? OUTPUT

Here are how the parameters are defined in the Execute SQL Task:

gv_VarInterval INPUT varchar 0

gv_Name1 INPUT varchar 1

gv_MaxDate OUTPUT datetime 2

(Variables used as input parameters defined as strings with package scope)

Here is the error I am getting:

[Execute SQL Task] Error: Executing the query "EXEC dbo.sp_Hist_Max_Dates ?, ?, ? OUTPUT" failed with the following error: "Error HRESULT E_FAIL has been returned from a call to a COM component.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

The connection is just OLEDB to SQL Server 2005. Any ideas why is this not working?

Thanks!

Kayda

Try adding the parameter name (as declared in the SP) and the '=' sign to the SQL command:

EXEC sp_Hist_Max_Dates @.Parametername1 = ?,@.Parametername2= ?, @.Parametername3 = ? OUTPUT

|||another cryptic error message? hardly surprising... check if the account under which a package is run, has rights to execute the stored procedure|||On your SQL Task, set the "BypassPrepare" to TRUE. Otherwise the validation tries to validate the ?'s, and can't.

Thursday, March 8, 2012

Can't remove SA account or delete xp_cmdshell ext stored proc?

I'm trying to make my SQL Server a tad more secure, but I'm unable to remove
SA (I'm running Mixed mode) -- can the SA account only be removed when using
windows Authentication? When I try to remove SA I get "selected user
cannot be dropped because the user owns objects". When I try to delect
xp_cmdshell I get the following error "You tried to delete one or more
system objects. They were not deleted."
I must admit, I'm a little confused, I'm trying to implement Microsofts
security recommendations, but either the documention is not
detailed/accurate or I'm missing something?
Any suggestions?
Thanks, Rob.Hi
You can not remove the SA account. Set a very complicated password for it,
write it down and put it in a safe.
For the xp_ look at
http://support.microsoft.com/defaul...kb;en-us;891984
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Rob R. Ainscough" wrote:

> I'm trying to make my SQL Server a tad more secure, but I'm unable to remo
ve
> SA (I'm running Mixed mode) -- can the SA account only be removed when usi
ng
> windows Authentication? When I try to remove SA I get "selected user
> cannot be dropped because the user owns objects". When I try to delect
> xp_cmdshell I get the following error "You tried to delete one or more
> system objects. They were not deleted."
> I must admit, I'm a little confused, I'm trying to implement Microsofts
> security recommendations, but either the documention is not
> detailed/accurate or I'm missing something?
> Any suggestions?
> Thanks, Rob.
>
>
>|||> I'm trying to make my SQL Server a tad more secure, but I'm unable to
> remove SA (I'm running Mixed mode) -- can the SA account only be removed
> when using windows Authentication? When I try to remove SA I get
> "selected user cannot be dropped because the user owns objects". When I
> try to delect xp_cmdshell I get the following error "You tried to delete
> one or more system objects. They were not deleted."
The sa login account cannot be deleted or renameed, nor it can't be revoked
any permission.

> I must admit, I'm a little confused, I'm trying to implement Microsofts
> security recommendations, but either the documention is not
> detailed/accurate or I'm missing something?
I don't think MS ever mentioned droping the sa account (as it can't be
done). Here are recommendations from Operations Guide: "
The sa account in a production environment should be given a complex
password, made up of uppercase and lowercase letters, symbols, spaces, and
numbers. The sa account should have a complex password, even if the SQL
Server is running in only Windows Authentication Mode. A complex password
protects SQL Server from someone easily getting administrative access to SQL
Server. This also protects the server in the event that an administrator
changes the security authentication mode to Mixed Mode.
Do not use the sa login account in a production environment. Instead, place
each DBA's network user account into a Windows group, create a single SQL
Server login account for the group then add the login account to the
sysadmin fixed server role. "
(http://www.microsoft.com/technet/pr...in/sqlops3.mspx
).
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com|||Thank you for the information.
The book I was reading is Microsoft Press and the authors are Ed Robinson
and Michael James Bond.
I have the SA password complex so no worries there.
I guess I'll leave the xp_cmdshell alone as it seems to be more trouble that
it is worth to remove it.
Should I think about installing URLScan ?
"Dejan Sarka" <dejan_please_reply_to_newsgroups.sarka@.avtenta.si> wrote in
message news:%23BAAU89pFHA.3112@.TK2MSFTNGP12.phx.gbl...
> The sa login account cannot be deleted or renameed, nor it can't be
> revoked any permission.
>
> I don't think MS ever mentioned droping the sa account (as it can't be
> done). Here are recommendations from Operations Guide: "
> The sa account in a production environment should be given a complex
> password, made up of uppercase and lowercase letters, symbols, spaces, and
> numbers. The sa account should have a complex password, even if the SQL
> Server is running in only Windows Authentication Mode. A complex password
> protects SQL Server from someone easily getting administrative access to
> SQL Server. This also protects the server in the event that an
> administrator changes the security authentication mode to Mixed Mode.
> Do not use the sa login account in a production environment. Instead,
> place each DBA's network user account into a Windows group, create a
> single SQL Server login account for the group then add the login account
> to the sysadmin fixed server role. "
> (http://www.microsoft.com/technet/pr...ityLearning.com
>|||> Should I think about installing URLScan ?
Why don't you ask this in some IIS group, with explanation why do you think
you need it?
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

Friday, February 24, 2012

can't modify stored proc which is in a publication

Hi

SQL 2005 sp1 - merge replication - HTTPS.

We have 2 publications for the database - one which has subscription.SyncType = SubscriptionSyncType.Automatic
and another with SyncType = SubscriptionSyncType.None.

The first publication is there so we can add new stored procs etc, the second contains the initial schema and the data.


When we try to modify a proc which is in the publication with SyncType = Automatic, the query never returns.

This is most urgent - thanks for your help.

Bruce

Do we have one or two subscriptions to publication one that contains the stored proc as a merge article in the publication?

|||

There are 2 subscriptions - one for each publication - but the proc is only in one publication

regards
Bruce

|||

1. Back to your original question - could the query (modifying the SP) be locked by another process so that it won't return?

2. Let us try to isolate this problem. If you can - colon the publication database, this publication (no second one), and subscribing database; does the same problem still occur?

Thanks.

|||

1. I doubt it..

2. 'colon the publication database' - what do you mean ?

thanks

|||

Create another publication database and create the same set of user tables/views/SPs. Just create one publication which includes the SP and other merge articles. See if you still can repro this issue with a single publication.

Thanks.

|||

We will try this tomorrow - but it's worth pointing out the following

a) the publication with SyncType = none -- has a few hundred stored procs - I can change any of these no worries

b) the publication with SyncType = automatic - initially just has 1 stored proc - so we can create the publication! - it's the procs we've added to this which we can't subsequently change.

Regards
Bruce

|||

Ok


I stripped it right back.

a. created a new database

b. added one proc

c. created the merge publication , snapshot etc

d. initalized ok

e. The query never returns....

Thanks
Bruce

|||

Can you share the proc prototype/definition (also I assume you use "ALTER PROCEDURE" to modify it)? I want to repro this case in house.

Thanks.

|||

Absolutely - it's a mindnumbing place-holder - it's just there so we can create the publication..

Don't laugh.

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

GO

--

-- This is the proc for the 'extras' subscription

--

--

ALTER PROCEDURE [dbo].[aaaaPlaceHolder]

AS

BEGIN

SET NOCOUNT ON;

SELECT 'fish', 'cow', 'dog', 'elephant', 'pig', 'moo', 's', 't', 'dog', 'sheep'

END

|||

Bruce,

Thanks for your help. I have repro-ed this scenario on my machine. I need to work with my peers to diagnoise the real cause of it. Should get back to you once I have the answer.

Regards,

Leo

This posting is provided "AS IS" with no warranties, and confers no rights.

|||

As a temp solution - a dummy table can be created to join the SP in the same publication so that SP can be modified and replicated to the subscriber.

Leo

This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Hi

I'll try it - has this been logged as a bug ? If so, how do I keep track of it ?

Thanks

|||

The bug was definitely filed and once I heard the decision/status I post it immediately.

Thanks

|||

This issue/bug should be addressed in Yukon Service Pack 2.

Leo

This posting is provided AS IS with no warranties, and confers no rights

can't modify stored proc which is in a publication

Hi

SQL 2005 sp1 - merge replication - HTTPS.

We have 2 publications for the database - one which has subscription.SyncType = SubscriptionSyncType.Automatic
and another with SyncType = SubscriptionSyncType.None.

The first publication is there so we can add new stored procs etc, the second contains the initial schema and the data.


When we try to modify a proc which is in the publication with SyncType = Automatic, the query never returns.

This is most urgent - thanks for your help.

Bruce

Do we have one or two subscriptions to publication one that contains the stored proc as a merge article in the publication?

|||

There are 2 subscriptions - one for each publication - but the proc is only in one publication

regards
Bruce

|||

1. Back to your original question - could the query (modifying the SP) be locked by another process so that it won't return?

2. Let us try to isolate this problem. If you can - colon the publication database, this publication (no second one), and subscribing database; does the same problem still occur?

Thanks.

|||

1. I doubt it..

2. 'colon the publication database' - what do you mean ?

thanks

|||

Create another publication database and create the same set of user tables/views/SPs. Just create one publication which includes the SP and other merge articles. See if you still can repro this issue with a single publication.

Thanks.

|||

We will try this tomorrow - but it's worth pointing out the following

a) the publication with SyncType = none -- has a few hundred stored procs - I can change any of these no worries

b) the publication with SyncType = automatic - initially just has 1 stored proc - so we can create the publication! - it's the procs we've added to this which we can't subsequently change.

Regards
Bruce

|||

Ok


I stripped it right back.

a. created a new database

b. added one proc

c. created the merge publication , snapshot etc

d. initalized ok

e. The query never returns....

Thanks
Bruce

|||

Can you share the proc prototype/definition (also I assume you use "ALTER PROCEDURE" to modify it)? I want to repro this case in house.

Thanks.

|||

Absolutely - it's a mindnumbing place-holder - it's just there so we can create the publication..

Don't laugh.

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

GO

--

-- This is the proc for the 'extras' subscription

--

--

ALTER PROCEDURE [dbo].[aaaaPlaceHolder]

AS

BEGIN

SET NOCOUNT ON;

SELECT 'fish', 'cow', 'dog', 'elephant', 'pig', 'moo', 's', 't', 'dog', 'sheep'

END

|||

Bruce,

Thanks for your help. I have repro-ed this scenario on my machine. I need to work with my peers to diagnoise the real cause of it. Should get back to you once I have the answer.

Regards,

Leo

This posting is provided "AS IS" with no warranties, and confers no rights.

|||

As a temp solution - a dummy table can be created to join the SP in the same publication so that SP can be modified and replicated to the subscriber.

Leo

This posting is provided "AS IS" with no warranties, and confers no rights.

|||

Hi

I'll try it - has this been logged as a bug ? If so, how do I keep track of it ?

Thanks

|||

The bug was definitely filed and once I heard the decision/status I post it immediately.

Thanks

|||

This issue/bug should be addressed in Yukon Service Pack 2.

Leo

This posting is provided AS IS with no warranties, and confers no rights