annethorne
Programmer
Hi,
I want to write a script for our Release Engineers to run that does the following (which doesn't even work though this is the general idea ... and doesn't require my cutting and pasting so much). I think I need to perhaps create some arrays, and use a while statement? But, there may be better ways. I want the Release Engineers to just be able to run the script and forget about it, not need to install a function or stored procedure to help run it.
The general prinicipal, is that I want the data inserted, if the LookupName is not there, but updated if it is.
BEGIN TRANSACTION
BEGIN
Declare @LookupName char(50);
Declare @LookupValueFound char(4000);
Declare @LookupValue char(4000);
Set @LookupName = 'Shelternet_IsActive';
Set @LookupValue = 'true';
SELECT @LookUpValueFound = LookUpValue FROM LookUps WHERE LookupName = @LookUpName
IF @LookupValueFound IS NULL
Begin
INSERT INTO Lookups (LookUpName, LookUpValue) VALUES ( @LookupName, @LookupValue)
End
ELSE
Begin
UPDATE dbo.LookUps SET LookUpValue = @LookupValue WHERE LookupName = @LookupName
End
Set @LookupName = 'Shelternet_Message';
Set @LookupValue = 'March 8th marks International Women’s Day.[BREAK]Shelternet is an organization that empowers women affected by violence.[BREAK][CUSTOMERS_NAME]:Would you like to add a $1 donation to this order to help make a difference?';
SELECT @LookUpValueFound = LookUpValue FROM LookUps WHERE LookupName = @LookUpName
IF @LookupValueFound IS NULL
Begin
INSERT INTO Lookups (LookUpName, LookUpValue) VALUES ( @LookupName, @LookupValue)
End
ELSE
Begin
UPDATE dbo.LookUps SET LookUpValue = @LookupValue WHERE LookupName = @LookupName
End
Set @LookupName = 'Shelternet_ProductNum';
Set @LookupValue = '214';
SELECT @LookUpValueFound = LookUpValue FROM LookUps WHERE LookupName = @LookUpName
IF @LookupValueFound IS NULL
Begin
INSERT INTO Lookups (LookUpName, LookUpValue) VALUES ( @LookupName, @LookupValue)
End
ELSE
Begin
UPDATE dbo.LookUps SET LookUpValue = @LookupValue WHERE LookupName = @LookupName
End
END
GO
Any advice is appreciated.
Thanks!
Anne
I want to write a script for our Release Engineers to run that does the following (which doesn't even work though this is the general idea ... and doesn't require my cutting and pasting so much). I think I need to perhaps create some arrays, and use a while statement? But, there may be better ways. I want the Release Engineers to just be able to run the script and forget about it, not need to install a function or stored procedure to help run it.
The general prinicipal, is that I want the data inserted, if the LookupName is not there, but updated if it is.
BEGIN TRANSACTION
BEGIN
Declare @LookupName char(50);
Declare @LookupValueFound char(4000);
Declare @LookupValue char(4000);
Set @LookupName = 'Shelternet_IsActive';
Set @LookupValue = 'true';
SELECT @LookUpValueFound = LookUpValue FROM LookUps WHERE LookupName = @LookUpName
IF @LookupValueFound IS NULL
Begin
INSERT INTO Lookups (LookUpName, LookUpValue) VALUES ( @LookupName, @LookupValue)
End
ELSE
Begin
UPDATE dbo.LookUps SET LookUpValue = @LookupValue WHERE LookupName = @LookupName
End
Set @LookupName = 'Shelternet_Message';
Set @LookupValue = 'March 8th marks International Women’s Day.[BREAK]Shelternet is an organization that empowers women affected by violence.[BREAK][CUSTOMERS_NAME]:Would you like to add a $1 donation to this order to help make a difference?';
SELECT @LookUpValueFound = LookUpValue FROM LookUps WHERE LookupName = @LookUpName
IF @LookupValueFound IS NULL
Begin
INSERT INTO Lookups (LookUpName, LookUpValue) VALUES ( @LookupName, @LookupValue)
End
ELSE
Begin
UPDATE dbo.LookUps SET LookUpValue = @LookupValue WHERE LookupName = @LookupName
End
Set @LookupName = 'Shelternet_ProductNum';
Set @LookupValue = '214';
SELECT @LookUpValueFound = LookUpValue FROM LookUps WHERE LookupName = @LookUpName
IF @LookupValueFound IS NULL
Begin
INSERT INTO Lookups (LookUpName, LookUpValue) VALUES ( @LookupName, @LookupValue)
End
ELSE
Begin
UPDATE dbo.LookUps SET LookUpValue = @LookupValue WHERE LookupName = @LookupName
End
END
GO
Any advice is appreciated.
Thanks!
Anne