[dba-VB] [dba-SQLServer] I'm baffled

Arthur Fuller fuller.artful at gmail.com
Wed Sep 23 08:42:14 CDT 2009


I tried this approach on one of my own databases and it worked just fine.
Given the differences in tables, I did a NOT NULL but that is beside the
point I think. Here is my sproc and an example call:
<sql>
IF EXISTS (
  SELECT *
    FROM INFORMATION_SCHEMA.ROUTINES
   WHERE SPECIFIC_SCHEMA = N'BOM'
     AND SPECIFIC_NAME = N'ap_CountByField'
)
   DROP PROCEDURE BOM.ap_CountByField
GO

CREATE PROCEDURE BOM.ap_CountByField
@fld_name varchar(100)
AS
SELECT COUNT(*)
FROM BOM.AssemblyComponents
WHERE @fld_name IS NOT NULL
GO

-- =============================================
-- Example to execute the stored procedure
-- =============================================
EXECUTE BOM.ap_CountByField 'AssemblyComponentID'
GO
</sql>

hth,
Arthur



More information about the dba-VB mailing list