Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF or CASE

Status
Not open for further replies.

aajaydee

Technical User
Oct 16, 2005
39
US
I'm new bee and need help
I'm trying to write store proc

but getting error here is what I'm trying to do
any help would be great

SELECT Import_Date, FileName as Import_File, DeletedDateTime
ErrorLine, ErrorsDetected, Notes,DELETED
FROM tblimporterrors
WHERE customerid = @customerid
AND ImportDate Between @startDate and @endDate
If @deleteonly = 1
BEGIN
DELETED = 1
END
 
IIF does not exist in SQL server. If you need to use a conditional inside of a sql statment use CAse. If you need to do procedurual code where differnt SQl code would run based on a set of conditions, use IF.



Questions about posting. See faq183-874
 
It's not clear what you're trying to do. Explain more, please.
 
I'm just trying to do
if parameter @deleteonly = 1
then in where caluse field name
DELETED = 1
else
DELETED=0

thanks
 
or in other words

iif(@deleteonly = 1,Deleted=1,Deleted=0)
 
What is Deleted? A column name? Are you trying to perform an UPDATE?

Look up UPDATE in SQL Server's built-in Books Online (BOL).

Code:
IF @deleteonly = 1
   UPDATE tblimporterrors 
   SET deleted = 1
   WHERE customerid = @customerid
   AND ImportDate Between @startDate and @endDate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top