Home > Archive > ASE Database forum > December 2005 > column name as proc argument









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author column name as proc argument
Scott R. Rouse

2005-12-07, 8:26 pm

Can I use a column as an argument for a procedure?

A simple example would be a proc that is passed a column name and
returns the number of nulls. This is not what I need, but should be a
simple example.

i.e. p_null_cnt COL

and have the procedure do something like:

select count(*) from mytable where COL is null




Scott
A Cornell

2005-12-07, 8:26 pm

yes, then you would have to generate the sql in the stored procedures like
the following

declare @sql varchar(500)
select @sql = "count(*) from mytable where ' + @column_name +' is null'
exec ( @sql )

"Scott R. Rouse" < srouse_at_sfbr_dot_o
rg> wrote in message
news:43975611$1@foru
ms-1-dub...
> Can I use a column as an argument for a procedure?
>
> A simple example would be a proc that is passed a column name and returns
> the number of nulls. This is not what I need, but should be a simple
> example.
>
> i.e. p_null_cnt COL
>
> and have the procedure do something like:
>
> select count(*) from mytable where COL is null
>
>
>
>
> Scott



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com