Re: Stored procedure

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks Nick, I actually did create them in the sql server, I just didn't how
to use them.


"Nick Malik [Microsoft]" wrote:

> Hello nbohana,
>
> Stored procedures do not live in C# code. They live in SQL Server
> databases. You need to use the SQL Enterprise Manager tool to find your
> database and open it. From there, assuming you have permission, you can add
> the stored procedure.
>
> Then, your C# code is free to call it.
>
> It is called a stored procedure because it is a procedure that is stored in
> the database.
>
> Also note:
> > INSERT INTO services([service-code], [service-description],
> > [large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES
> > (@Param1, @Param2, @Param3, @Param4, @Param5, @filler);
>
> This is not a valid SQL statement. Your Insert Into statement has to have
> the same number of fields in the first half as values in the second. You
> have five fields in the first half, and six values in the second. I don't
> know what "filler" means to you, but to me, it sounds like something we used
> to use in ISAM databases (yes... my hair is grey in spots :-). Filler
> fields are not used in SQL Server except in rare situations. My guess is
> that you are applying information from another DB to the SQL Server system.
>
> Also note:
> > SELECT [service-code], [service-description], [large-animal-cost],
> > [medium-animal-cost], [small-animal-cost], [service-nbr] FROM services
> > WHERE
> > ([service-nbr] = @@IDENTITY) ORDER BY [service-code];
>
> The Order By clause is unnecessary. The Select statement above will only
> select a single record, ever.
>
> Also, using Identity columns is not always scalable. (In other words, it
> becomes a hassle if you need to have multiple databases that share records).
> May I suggest that you could use a 'uniqueidentifier' column, and that your
> C# app would create the value (Guid.NewGuid()) and pass it with the new
> record, rather than having the database create it? It's a good habit to
> have.
>
> Hope this helps,
>
> --
> --- Nick Malik [Microsoft]
> MCSD, CFPS, Certified Scrummaster
> http://blogs.msdn.com/nickmalik
>
> Disclaimer: Opinions expressed in this forum are my own, and not
> representative of my employer.
> I do not answer questions on behalf of my employer. I'm just a
> programmer helping programmers.
> --
> "nbohana" <nbohana@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:DEF88E77-088E-48DD-B719-790A40F61038@xxxxxxxxxxxxxxxx
> >I am trying to code an compile a stored procedure without success. So I
> > generated one using Microsoft Visule C# .Net. and it follows. One of the
> > problems is that it will not compile. Some of the message won't to put ';'
> > all over the place, I some need help!!! These are some of the compile
> > messages.
> >
> > ; expected
> > Cannot use more than one type in a for, using, fixed, or declaration
> > statement
> > = (cannot specify constructor arguments in declaration)
> > Identifier expected
> > Invalid expression term ')'
> > Invalid expression term ','
> >
> > static void SubmitChangesViaDataAdapter()
> > {
> > IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandDetail' AND
> > user_name(uid) = 'dbo')
> > DROP PROCEDURE [dbo].[InsertCommandDetail];
> > GO
> >
> > CREATE PROCEDURE [dbo].[InsertCommandDetail]
> > {
> > @Param1 int,
> > @Param2 char(30),
> > @Param3 money,
> > @Param4 money,
> > @Param5 money,
> > @filler char(50)
> > }
> > AS
> > SET NOCOUNT OFF;
> > INSERT INTO services([service-code], [service-description],
> > [large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES
> > (@Param1, @Param2, @Param3, @Param4, @Param5, @filler);
> > SELECT [service-code], [service-description], [large-animal-cost],
> > [medium-animal-cost], [small-animal-cost], [service-nbr] FROM services
> > WHERE
> > ([service-nbr] = @@IDENTITY) ORDER BY [service-code];
> > GO
> >
> > }
> >
> > --
> > Norm Bohana
>
>
>
.



Relevant Pages

  • Re: Stored procedure
    ... the stored procedure. ... to use in ISAM databases (yes... ... fields are not used in SQL Server except in rare situations. ... > @Param3 money, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to get list of EventClasses in MSSQLServer2000
    ... statement inside a stored procedure has completed.') ... SQL Server statement or stored procedure.') ... Plan','Displays the plan tree of the Transact-SQL statement executed.') ... Login','Occurs when a SQL Server login is added or removed; ...
    (microsoft.public.sqlserver.security)
  • How to query two SQL Server instances
    ... I need to run a stored procedure, or make it simpler, to run a query to ... access the databases from two machines location at different locations. ... On client's machine A, say in city A, have installed SQL Server, another ... the databases in head office? ...
    (microsoft.public.sqlserver.programming)
  • Re: Accessing FoxPro Free Table
    ... which the SQL Server service is running. ... account, ... > If you are creating a stored procedure and you want> to make sure that the procedure definition cannot be> viewed by other users, you can use the WITH ENCRYPTION> clause. ... The procedure definition is then stored in an> unreadable form. ...
    (microsoft.public.data.odbc)
  • Stored procedure does not complete until result set is retrieved from ODBC
    ... I have a SQL Server Stored procedure that I am executing via ODBC. ... -- Start Code without cursor ...
    (microsoft.public.sqlserver.odbc)