Create Procedure [dbo].[spGenerateID]
(
@sFieldName NVARCHAR(100),
@sTableName NVARCHAR(100)
)
AS
BEGIN
SELECT ISNULL(MAX(ISNULL(@sFieldName, 0)), 0) + 1 FROM @sTableName
END
In the above procedure I supply the field name and table name and I want the max number of this field .Why this not work?I also want to check if those fields are null than it's not work.. This procedure must have a return parameter of the field that I supplied which contain the max number.Please help me to fixed it.
- Why does this not work.
- How to check input parameter are not null.
- How to set output parameter