On Fri, Jan 14, 2011 at 5:48 AM, Rafael Copquin <[email protected]> wrote:
> I want to write a SP in SQL Server, where I would send three parameters
> and get one result, like so:
>
> 1st param a table name
> 2nd param a field name in that table
> 3rd param a value
>
> I would like to concatenate all three parameters inside the SQL SP to
> get something like this
>
> select (fieldname) from (table name) where (fieldname) = value
>
> and I would like to return that value to VFP.
>
> IOW, I want to create a stored procedure to be able to check the
> existence/non existence of a value in a table, to replace the seek
> command in VFP
>
> for instance
>
> select account from customers where account = 'RAF1234'
>
> if the account exists, I want to receive a positive value and if it does
> not, a negative one
>
> How is this done?
> please write the stored procedure for me, since I'm new to SQL Server
--------------
As a heads up you cannot pass a table object as varchar text to a SP
in SQL Server.
CREATE PROCEDURE testParams
(
@tableName [varchar] (50),
@columnName [varchar] (50),
@ID int (50)
)
AS
BEGIN
select @columnName from @tableName where ID = @ID
END
GO
This will not work because the From @tableName will not work.
You could make dynamic SQL within the SP but why do that when you can
generate the same string in VFP and pass that in as well?
--
Stephen Russell
Sr. Production Systems Programmer
CIMSgts
901.246-0159 cell
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.