Hi all, hope you can help,

I have a problem with an SQL command, and hope you can help me out.

Kinda new to SQL so finding the answer difficult to find, but I think it's to do with an UPDATE statement (at a guess)

I have a function that executes a stored procedure (spUpdateStoreDetails) that updates a table, but when i run the procedure only one of the two columns gets updated (fk_windowID). I need both the fk_window and fk_floorplans to get updated

here is the query

CREATE PROCEDURE [dbo].[spUpdateStoreDetails]
@iStoreID DECIMAL
,@sOpensMonday VARCHAR(8)
,@sClosesMonday VARCHAR(8)
,@sOpensTuesday VARCHAR(8)
,@sClosesTuesday VARCHAR(8)
,@sOpensWednesday VARCHAR(8)
,@sClosesWednesday VARCHAR(8)
,@sOpensThursday VARCHAR(8)
,@sClosesThursday VARCHAR(8)
,@sOpensFriday VARCHAR(8)
,@sClosesFriday VARCHAR(8)
,@sOpensSaturday VARCHAR(8)
,@sClosesSaturday VARCHAR(8)
,@sOpensSunday VARCHAR(8)
,@sClosesSunday VARCHAR(8)
,@sTelNumber VARCHAR(50)
,@sFaxNumber VARCHAR(50)
,@sEmailAddress VARCHAR(250)
,@sSocialProfileAddress VARCHAR(250)
,@sPostalAddress VARCHAR(500)
,@iWindowID DECIMAL
,@ifloorID DECIMAL
AS
BEGIN
SET NOCOUNT ON

IF EXISTS (SELECT fk_storeID FROM tblStoreDetails WHERE fk_storeID = @iStoreID)
BEGIN
UPDATE tblStoreDetails
SET
OpensMonday = @sOpensMonday
,ClosesMonday = @sClosesMonday
,OpensTuesday = @sOpensTuesday
,ClosesTuesday = @sClosesTuesday
,OpensWednesday = @sOpensWednesday
,ClosesWednesday = @sClosesWednesday
,OpensThursday = @sOpensThursday
,ClosesThursday = @sClosesThursday
,OpensFriday = @sOpensFriday
,ClosesFriday = @sClosesFriday
,OpensSaturday = @sOpensSaturday
,ClosesSaturday = @sClosesSaturday
,OpensSunday = @sOpensSunday
,ClosesSunday = @sClosesSunday
,TelNumber = @sTelNumber
,FaxNumber = @sFaxNumber
,EmailAddress = @sEmailAddress
,SocialProfileAddress = @sSocialProfileAddress
,PostalAddress = @sPostalAddress
,fk_windowID = @iWindowID
,fk_floorplansID = @ifloorID
WHERE
fk_StoreID = @iStoreID

END
ELSE
BEGIN
INSERT INTO tblStoreDetails (
fk_StoreID
,OpensMonday
,ClosesMonday
,OpensTuesday
,ClosesTuesday
,OpensWednesday
,ClosesWednesday
,OpensThursday
,ClosesThursday
,OpensFriday
,ClosesFriday
,OpensSaturday
,ClosesSaturday
,OpensSunday
,ClosesSunday
,TelNumber
,FaxNumber
,EmailAddress
,SocialProfileAddress
,PostalAddress
,fk_windowID
,fk_floorplansID
)
VALUES (
@iStoreID
,@sOpensMonday
,@sClosesMonday
,@sOpensTuesday
,@sClosesTuesday
,@sOpensWednesday
,@sClosesWednesday
,@sOpensThursday
,@sClosesThursday
,@sOpensFriday
,@sClosesFriday
,@sOpensSaturday
,@sClosesSaturday
,@sOpensSunday
,@sClosesSunday
,@sTelNumber
,@sFaxNumber
,@sEmailAddress
,@sSocialProfileAddress
,@sPostalAddress
,@iWindowID
,@ifloorID
)
END
END

Please can someone have a look at this and tell me if there is a problem with this query, or could if it could be somehting else?

if you need more information please shout.

kind regards
MG