|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
use sp as default column valuedefault value for a column as the return value from a stored procedure within enterprise manager, when I enter the sp in the column Default Value , em forces this to be a quoted string. ie entering dbo.MySP for the default value em converts this to 'dbo.MySP' for whatever reason, em doesn't recognize the sp if i do this using a udf, entering dbo.MyUDF]() for the default value works. CREATE PROCEDURE [dbo].[MySP] AS return 'hooha' GO CREATE FUNCTION [dbo].[MyUDF]() RETURNS varchar AS return 'hooha' GO Gerry It is not possible to use a sp for a default value.
-- Show quoteAndrew J. Kelly SQL MVP "gerry" <germ@nospam.nospam> wrote in message news:uszHsIt0GHA.2636@TK2MSFTNGP06.phx.gbl... >i am trying to do what i would think is a very simple thing, define the > default value for a column as the return value from a stored procedure > > within enterprise manager, when I enter the sp in the column Default Value > , > em forces this to be a quoted string. > ie entering dbo.MySP for the default value em converts this to 'dbo.MySP' > for whatever reason, em doesn't recognize the sp > > if i do this using a udf, entering dbo.MyUDF]() for the default value > works. > > CREATE PROCEDURE [dbo].[MySP] > AS > return 'hooha' > GO > > CREATE FUNCTION [dbo].[MyUDF]() > RETURNS varchar > AS > return 'hooha' > GO > > Gerry > > You can't use a stored procedure as a default value. The SQL Server Books
Online states: <Excerpt href="mk:@MSITStore:C:\Program%20Files\Microsoft%20SQL%20Server\80\Tools\Books\tsqlref.chm::/ts_create2_8g9x.htm"> A DEFAULT definition can contain constant values, functions, SQL-92 niladic functions, or NULL. </Excerpt> A couple of other issues too. A stored procedure RETURN statement can only return an integer. Furthermore, the Best Practice is to use the return value to indicate success or failure rather than return data. Data can be returned from stored procedures using output parameters or result sets. -- Show quoteHope this helps. Dan Guzman SQL Server MVP "gerry" <germ@nospam.nospam> wrote in message news:uszHsIt0GHA.2636@TK2MSFTNGP06.phx.gbl... >i am trying to do what i would think is a very simple thing, define the > default value for a column as the return value from a stored procedure > > within enterprise manager, when I enter the sp in the column Default Value > , > em forces this to be a quoted string. > ie entering dbo.MySP for the default value em converts this to 'dbo.MySP' > for whatever reason, em doesn't recognize the sp > > if i do this using a udf, entering dbo.MyUDF]() for the default value > works. > > CREATE PROCEDURE [dbo].[MySP] > AS > return 'hooha' > GO > > CREATE FUNCTION [dbo].[MyUDF]() > RETURNS varchar > AS > return 'hooha' > GO > > Gerry > > |
|||||||||||||||||||||||