Drop Table
Support Forum for database administrators and web based access to important newsgroups related to databasesIf I run this statement in Query Analyzer, it properly returns 1
for my testing table. But if I put the statement into a stored
procedure, the stored procedure returns NULL. What am I doing
wrong? I suspect it may be related to how I defined the parameters
for the stored procedure. Perhaps my definition of TableName and
ColumnName don't match what COLUMNPROPERTY and OBJECT_ID expect to
receive, but I don't know where to look for the function declarations
for those. Any pointers would be appreciated.
Select statement:
SELECT COLUMNPROPERTY(OBJEC
T_ID('Table1'), 'TestID', 'IsIdentity') AS
IsIdentity
Table definition:
CREATE TABLE [dbo].[Table1] (
[TestID] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[Description] [varchar] (50) COLLATE SQL_Latin1_General_C
P1_CI_AS NO
T NULL
) ON [PRIMARY]
Stored Procedure definition:
CREATE PROCEDURE spTest
(@TableName varchar,
@ColumnName varchar)
AS SELECT COLUMNPROPERTY(OBJEC
T_ID(@TableName), @ColumnName,
'IsIdentity') AS IsIdentity
Post Follow-up to this messageYou need to specify lengths for your varchar parameters CREATE PROCEDURE spTest (@TableName varchar(50), @ColumnName varchar(50))
Post Follow-up to this messagemarkc600@hotmail.com wrote: > You need to specify lengths for your varchar parameters > > CREATE PROCEDURE spTest > (@TableName varchar(50), > @ColumnName varchar(50)) That was it. Thanks.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread