Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / March 2008

Tip: Looking for answers? Try searching our database.

Cannot use the OUTPUT option when passing a constant Stored Proced

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stephen - 07 Mar 2008 22:13 GMT
I am having a very difficult problem.
I get the following error:
Microsoft SQL Native Client
Cannot use the OUTPUT option when passing a constant to a Stored Procedure

In SQL 2005 SP2, I check Profiler, here are my findings:
UserA (w/ Domain Admin rights in ADUC) - SQL Profiler reports that user exec
this sp as "dbo"
UserB (w/out Domain Admin rights in ADUC) - SQL Profiler reports that user
exec this sp as "DOMAIN\UserName"
If I change UserB to w/ Domain Admin rights in ADUC - SQL Profiler reports
that user exec this sp as "dbo".
What is going on? This started after updating SQL 2005 to SP2.
Thanks
Stephen
Andrew J. Kelly - 08 Mar 2008 14:11 GMT
Can you tell us more about how exactly you are calling this sp?  Can you
show the actual code?

Signature

Andrew J. Kelly    SQL MVP
Solid Quality Mentors

>I am having a very difficult problem.
> I get the following error:
[quoted text clipped - 12 lines]
> Thanks
> Stephen
Stephen - 10 Mar 2008 18:41 GMT
Yes, I will post it in about 2 hours.
Thanks
Stephen

> Can you tell us more about how exactly you are calling this sp?  Can you
> show the actual code?
[quoted text clipped - 15 lines]
> > Thanks
> > Stephen
Dan Guzman - 08 Mar 2008 16:07 GMT
> Cannot use the OUTPUT option when passing a constant to a Stored Procedure

I can reproduce this error message with the following test script:

EXEC dbo.test 1 OUT

So it would seem that your application is doing something similar; a
constant cannot be passed as an output parameter.

> In SQL 2005 SP2, I check Profiler, here are my findings:
> UserA (w/ Domain Admin rights in ADUC) - SQL Profiler reports that user
[quoted text clipped - 5 lines]
> that user exec this sp as "dbo".
> What is going on? This started after updating SQL 2005 to SP2.

I don't see how this information is related to the subject of this post but
this is expected behavior.  Administrators are SQL Server sysadmin role
members by default and are therefore the "dbo" user in all databases.
Non-sysadmin role members access databases under their normal database user
security context.

Signature

Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

>I am having a very difficult problem.
> I get the following error:
[quoted text clipped - 12 lines]
> Thanks
> Stephen
Stephen - 12 Mar 2008 21:56 GMT
Dan, I am sorry but I don't understand your reply.
I listed the information because that is all I know about how I can get this
sp to work... by giving my ADUsers "Domain Admin" rights.
So is it an sp issue or a permission problem? Sorry for not understanding
your reply.

Here is the sp:
USE [Database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[cf_data_info]
    @table_name varchar(128),
    @column_name varchar(128),
    @data_type varchar(128) OUTPUT,
    @colprecision integer OUTPUT,
    @colscale integer OUTPUT
AS
    SELECT @data_type = systypes.name,
        @colprecision = syscolumns.prec,
        @colscale = syscolumns.scale
    FROM sysobjects
    LEFT OUTER JOIN syscolumns
        ON syscolumns.id = sysobjects.id
    LEFT OUTER JOIN systypes
       
        ON systypes.xusertype = syscolumns.xusertype
    INNER JOIN sysusers
        ON sysusers.uid = sysobjects.uid
        AND Upper(sysusers.name) = 'DBO'
    WHERE sysobjects.name = @table_name
        AND syscolumns.name = @column_name

Everything worked fine before upgrading to SQL 2005 SP2.

Thanks
Stephen

> > Cannot use the OUTPUT option when passing a constant to a Stored Procedure
>
[quoted text clipped - 37 lines]
> > Thanks
> > Stephen
Dan Guzman - 13 Mar 2008 02:10 GMT
> So is it an sp issue or a permission problem? Sorry for not understanding
> your reply.

I think you are getting this error because the actual call to this procedure
is not formed correctly.  For example, the code below attempts to pass
literals as OUTPUT parameters:

DECLARE
   @data_type sysname,
   @colprecision int,
   @colscale int

EXEC [dbo].[cf_data_info]
   @table_name = 'MyTable',
   @column_name = 'MyColumn',
   @data_type = 'test' OUTPUT,
   @colprecision = 4 OUTPUT,
   @colscale = 2 OUTPUT

I can't explain how permissions might come into play here.  Does the
profiler trace show the execute statement?

Signature

Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

> Dan, I am sorry but I don't understand your reply.
> I listed the information because that is all I know about how I can get
[quoted text clipped - 87 lines]
>> > Thanks
>> > Stephen
Randy Pitkin - 13 Mar 2008 04:58 GMT
The issue is that the reference to the output needs to be declared in the
execution.
The error is in your execute call "EXEC dbo.test 1 OUT"

       Declare @InAndOutParammeterName
       Select @InAndOutParammeterName=1

           EXEC dbo.test @InAndOutParammeterName OUT

@InAndOutParammeterName now holds the reference in memory for the returned
value to reside.

> Dan, I am sorry but I don't understand your reply.
> I listed the information because that is all I know about how I can get
[quoted text clipped - 87 lines]
>> > Thanks
>> > Stephen
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.