Wrox Programmer Forums
|
BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6
This is the forum to discuss the Wrox book Beginning SQL Server 2005 Programming by Robert Vieira; ISBN: 9780764584336
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning SQL Server 2005 Programming ISBN: 978-0-7645-8433-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2007, 08:31 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update Stored Procedure - Help needed

Hi All

Can someone clever please help me with my update Stored procedure - it will be hugely appriciated.

I have 3 tables:
tblContainer
    ContNum (PK) smallint
    Length smallint
    StopDistance smallint
    ContTypeID tinyint
    HaulID tinyint

tblContTypes
    ContTypeID tinyint
    ContType nvarchar(30)
    ContNumFrom smallint
    ContNumTo smallint

tblHaul
    HaulID tinyint
    Haul nvarchar(30)

I have the following InsertProcedure which seems to work fine...
dbo.usp_InsertContainer
(
    @ContNum smallint,
    @Length smallint,
    @StopDistance smallint,
    @ContType nvarchar(30),
    @Haul nvarchar(30)
)
AS
    INSERT INTO dbo.tblContainer(ContNum, Length, StopDistance, ContTypeID, HaulID)
SELECT
    @ContNum
    @Length
    @StopDistance
        (SELECT HaulID FROM dbo.tblHaul WHERE Haul=@Haul)
        (SELECT ContTypeID FROM dbo.tblContTypes WHERE @ContNum BETWEEN ContNumFrom AND ContNumTo)

I have tried to code an usp_UpdateContainer:
(
    @ContNum smallint,
    @Length smallint,
    @StopDistance smallint,
    @ContType nvarchar(30),
    @Haul nvarchar(30)
)
AS
    UPDATE dbo.tblContainer
        (SELECT HaulID FROM dbo.tblHaul WHERE Haul = @Haul),
        (SELECT ContTypeID FROM dbo.tblContTyper WHERE @ContNum BETWEEN ContNumFrom AND ContNumTo),
        SET
        ContNum = @ContNum,
        Length = @Length,
        StopDistance = @StopDistance,
    WHERE ContNum = @ContNum

 Can you please guide me as to what I am doing wrong in the update procedure?

Thanks a bunch


Kind regards
Tina Nielsen, Denmark





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored procedure - batch update timeware SQL Server ASP 2 December 12th, 2007 04:13 PM
ADP Update Stored Procedure ashg657 Access 0 June 2nd, 2006 05:29 AM
Update Tables in Stored Procedure Talsiter SQL Server 2005 1 April 10th, 2006 03:32 PM
How to update diffgram through stored procedure rajjr SQL Server ASP 0 March 3rd, 2006 02:17 AM
Help on C#/Stored Procedure/SqlClient Needed. peri C# 0 December 14th, 2004 04:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.