Thanks, Stephen, good tip.

Rafael

----- Original Message ----- 
From: "Stephen Russell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 19, 2008 11:04 AM
Subject: Re: stored procedures in SQL


> On Tue, Nov 18, 2008 at 6:19 PM, Rafael Copquin <[EMAIL PROTECTED]> 
> wrote:
>> Perhaps this qualifies as NF, but then, it is a pure VFP question.
>>
>> I am doing my first steps in SQL Server, using SQL Server 2005 Express 
>> edition. I just want  to create a stored procedure in SQL Server, so I 
>> can do the following:
>>
>> Create a connection in a VFP form
>> call the stored procedure (passing for instance a customer PK), so the 
>> procedure will return the customer name, address, email, etc.
>>
>> A very simple sql call.
>>
>> But how do you create the procedure in the SQL engine? Or should I ask 
>> this question in a SQL forum?
>>
> --------------------------------
>
> Do you know how to write SPs for SQL Server?   This from the template
> in SQL 2005
>
> -- =============================================
> -- Author: <Author,,Name>
> -- Create date: <Create Date,,>
> -- Description: <Description,,>
> -- =============================================
> CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName>
> -- Add the parameters for the stored procedure here
> <@Param1, sysname, @p1> <Datatype_For_Param1, , int> =
> <Default_Value_For_Param1, , 0>,
> <@Param2, sysname, @p2> <Datatype_For_Param2, , int> =
> <Default_Value_For_Param2, , 0>
> AS
> BEGIN
> -- SET NOCOUNT ON added to prevent extra result sets from
> -- interfering with SELECT statements.
> SET NOCOUNT ON;
>
>    -- Insert statements for procedure here
> SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
> END
> GO
>
> I have this:
> create procedure GetPerson
>    @ContactID [int]
> as
>
> SELECT [ContactID]
>      ,[NameStyle]
>      ,[Title]
>      ,[FirstName]
>      ,[MiddleName]
>      ,[LastName]
>      ,[Suffix]
>      ,[EmailAddress]
>      ,[EmailPromotion]
>      ,[Phone]
>      ,[PasswordHash]
>      ,[PasswordSalt]
>      ,[AdditionalContactInfo]
>      ,[rowguid]
>      ,[ModifiedDate]
>  FROM [AdventureWorks].[Person].[Contact]
> where ContactID = @ContactID
> go
>
>
> make that a string and execute that statement against the db of your
> choice/connection string.
>
> You now have what you want on the server.
>
>
>
> -- 
> Stephen Russell
> Sr. Production Systems Programmer
> Mimeo.com
> Memphis TN
>
> 901.246-0159
>
>
[excessive quoting removed by server]

_______________________________________________
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.

Reply via email to