question

artistlover avatar image
artistlover asked

SQL 2008 Stored Procedure

This is a small portion of a stored procedure. I have to code it so that if tmpclaimsproperties.value is 18 don't do the following delete or insert. I have no clue how to do that. I tried if tmpclaimsproperties.value 18 begin end Then code below was between the begin and end. Error is that value cannot be bound. Ideas? --**Delete existing status records from tmpclaimsProperties Delete from tmpclaimsproperties where [control num] in (select distinct [clm spec 2] from tmpclaims_preloadTemp) and property = 'status' --**Write new status 13 records for claims identified in tmpclaims_preloadTemp Insert into tmpclaimsproperties ([control num], [Org control num], [rec num], [property], [value], operator, dtmadded ) Select distinct [clm spec 2],[clm spec 2],'9649','Status','18','Sync',getdate() from tmpclaims_preloadTemp where [clm spec 2] is not null
stored-procedures
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Squirrel avatar image Squirrel commented ·
where is tmpclaimsproperties.value comes from ? is it an earlier part of the stored procedure ? Can you show us that part as well ?
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
This web site runs from voting. For any helpful answer, please indicate this by clicking on the thumbs up next to those answers. If any one answer lead to a solution, please indicate this by clicking on the check mark next to that answer.
0 Likes 0 ·
DenisT avatar image
DenisT answered
You cannot use if tmpclaimsproperties.value 18. You have to declare a variable and then assign a value to it.
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

artistlover avatar image artistlover commented ·
i just do not know how to do this.
0 Likes 0 ·
artistlover avatar image artistlover commented ·
how about this declare @objectid int set @objectid = OBJECT_ID(N'dbo.tmpclaim_preloadtemp.status'); if @objectid 18 begin then end at end
0 Likes 0 ·
Squirrel avatar image
Squirrel answered
> how about this declare @objectid int > set @objectid = > OBJECT_ID(N'dbo.tmpclaim_preloadtemp.status'); > if @objectid 18 begin then end at > end maybe this is what you want ? Select distinct [clm spec 2],[clm spec 2],'9649','Status','18','Sync',getdate() from tmpclaims_preloadTemp where [clm spec 2] is not null and status '18'
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.