Sunday, February 19, 2012

Data insertion using stored procedure.

Hi kind of new to SQL. Anyhow I want to use a stored procedure to do the
following field insertion into a table, just wondering what statements to use.
table name = tabletest
*****************************
* primary key * varchar * integer *
*****************************
* 1 * test * 34 *
*****************************
* 2 * test2 * 21 *
*****************************
The input to the procedure is a 2, and I want the procedure to replace
the 21 with another integer (say 5) while leaving the rest of the row
unchanged, still contains string test2 and primary key 2.
Thanks.
--
Paul G
Software engineer.Read about the UPDATE command. An example (no column names were given...):
CREARE PROC procname
@.col1 int
AS
UPDATE tabletest
SET col3 = 5
WHERE col1 = @.col1
GO
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Paul" <Paul@.discussions.microsoft.com> wrote in message
news:6A3AA6DC-BC23-446D-A2B4-26A1602BDDF1@.microsoft.com...
> Hi kind of new to SQL. Anyhow I want to use a stored procedure to do the
> following field insertion into a table, just wondering what statements to use.
> table name = tabletest
> *****************************
> * primary key * varchar * integer *
> *****************************
> * 1 * test * 34 *
> *****************************
> * 2 * test2 * 21 *
> *****************************
> The input to the procedure is a 2, and I want the procedure to replace
> the 21 with another integer (say 5) while leaving the rest of the row
> unchanged, still contains string test2 and primary key 2.
> Thanks.
>
> --
> Paul G
> Software engineer.|||ok, thanks for the information.
"Tibor Karaszi" wrote:
> Read about the UPDATE command. An example (no column names were given...):
> CREARE PROC procname
> @.col1 int
> AS
> UPDATE tabletest
> SET col3 = 5
> WHERE col1 = @.col1
> GO
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Paul" <Paul@.discussions.microsoft.com> wrote in message
> news:6A3AA6DC-BC23-446D-A2B4-26A1602BDDF1@.microsoft.com...
> > Hi kind of new to SQL. Anyhow I want to use a stored procedure to do the
> > following field insertion into a table, just wondering what statements to use.
> > table name = tabletest
> > *****************************
> > * primary key * varchar * integer *
> > *****************************
> > * 1 * test * 34 *
> > *****************************
> > * 2 * test2 * 21 *
> > *****************************
> > The input to the procedure is a 2, and I want the procedure to replace
> > the 21 with another integer (say 5) while leaving the rest of the row
> > unchanged, still contains string test2 and primary key 2.
> > Thanks.
> >
> >
> > --
> > Paul G
> > Software engineer.
>
>

No comments:

Post a Comment