-
Better SQL Code
Hello All,
I have a set of upate queries that run in a SQL Stored Procedure on MSSQL2000.
That look like this:
IF @Corrections NOT IN (SELECT [Corrections] FROM [WEB_WIPSTATNEW]
WHERE [WEB_WIPSTATNEW].[JobNumber] = @jobnumber
AND [WEB_WIPSTATNEW].[BoardNumber] = @boardnumber)
BEGIN
UPDATE [WEB_WIPSTATNEW]
SET
[Corrections] = @corrections,
[CorrectionsDate] = @current_datetime,
[CorrectionsAuth] = @user
WHERE [WEB_WIPSTATNEW].[JobNumber] = @jobnumber
and [WEB_WIPSTATNEW].[Boardnumber] = @BoardNumber
END
I have more than twenty of these in there. I'm sure that there is a more
efficient way to write this, any ideas? Thanks in advance!
-
Re: Better SQL Code
IF NOT EXISTS (SELECT Corrections
FROM WEB_WIPSTATNEW
WHERE job.Number = @jobNumber
AND BoardNumber = @boardNumber
AND corrections = @corrections)
UPDATE WEB_WIPSTATNEW
SET Corrections = @corrections,
CorrectionsDate = @current_datetime,
CorrectionsAuth = user
WHERE JobNumber = @jobNumber
AND BoardNumber = @boardNumber
"Edwin" <vbedluciano@hotmail.com> wrote:
>
>Hello All,
>I have a set of upate queries that run in a SQL Stored Procedure on MSSQL2000.
>That look like this:
>
>IF @Corrections NOT IN (SELECT [Corrections] FROM [WEB_WIPSTATNEW]
> WHERE [WEB_WIPSTATNEW].[JobNumber] = @jobnumber
> AND [WEB_WIPSTATNEW].[BoardNumber] = @boardnumber)
>
> BEGIN
> UPDATE [WEB_WIPSTATNEW]
> SET
> [Corrections] = @corrections,
> [CorrectionsDate] = @current_datetime,
> [CorrectionsAuth] = @user
>
>WHERE [WEB_WIPSTATNEW].[JobNumber] = @jobnumber
> and [WEB_WIPSTATNEW].[Boardnumber] = @BoardNumber
> END
>
>I have more than twenty of these in there. I'm sure that there is a more
>efficient way to write this, any ideas? Thanks in advance!
-
Re: Better SQL Code
THANK YOU SO MUCH
"Yuji" <ynakagawa@devx.com> wrote:
>
>IF NOT EXISTS (SELECT Corrections
> FROM WEB_WIPSTATNEW
> WHERE job.Number = @jobNumber
> AND BoardNumber = @boardNumber
> AND corrections = @corrections)
>
> UPDATE WEB_WIPSTATNEW
> SET Corrections = @corrections,
> CorrectionsDate = @current_datetime,
> CorrectionsAuth = user
> WHERE JobNumber = @jobNumber
> AND BoardNumber = @boardNumber
>
>"Edwin" <vbedluciano@hotmail.com> wrote:
>>
>>Hello All,
>>I have a set of upate queries that run in a SQL Stored Procedure on MSSQL2000.
>>That look like this:
>>
>>IF @Corrections NOT IN (SELECT [Corrections] FROM [WEB_WIPSTATNEW]
>> WHERE [WEB_WIPSTATNEW].[JobNumber] = @jobnumber
>> AND [WEB_WIPSTATNEW].[BoardNumber] = @boardnumber)
>>
>> BEGIN
>> UPDATE [WEB_WIPSTATNEW]
>> SET
>> [Corrections] = @corrections,
>> [CorrectionsDate] = @current_datetime,
>> [CorrectionsAuth] = @user
>>
>>WHERE [WEB_WIPSTATNEW].[JobNumber] = @jobnumber
>> and [WEB_WIPSTATNEW].[Boardnumber] = @BoardNumber
>> END
>>
>>I have more than twenty of these in there. I'm sure that there is a more
>>efficient way to write this, any ideas? Thanks in advance!
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks