About 321,000 results
Open links in new tab
  1. sql server - using if statement in sql function - Stack Overflow

    May 2, 2011 · SET @i = @iNumber * dbo.Factorial( @iNumber - 1 ) The problem you have is in part the syntax of the if statement in TSQL, the right thing to do is: declare @Result int. set …

  2. How to Execute an IF…THEN Logic in an SQL SELECT Statement

    May 28, 2024 · We can use either a CASE statement or an IIF() function to implement IF-THEN logic in SQL. In this tutorial, we’ll explore how to implement IF-THEN logic in SQL across …

  3. SQL IF Statement for Conditional Logic - SQL Server Tips

    Sep 12, 2022 · I’m learning T-SQL and need to know how to use an IF statement to include conditional statements within a stored procedure, function, trigger, or script in Microsoft SQL …

  4. How to Use If Else in SQL Select Statement - GeeksforGeeks

    Jan 2, 2025 · By using IF...ELSE within SQL statements we can categorize data, apply conditional transformations, and implement business logic directly in our queries. In this article, We will …

  5. Conditional function IF — Interactive SQL Course - SQL Academy

    IF (conditional_expression, value_under_true_condition, value_on_false_condition); The IF function looks at the truth of the conditional expression and, depending on this truth, returns …

  6. If Else If In a Sql Server Function - Stack Overflow

    Feb 17, 2011 · You'll need to create local variables for those columns, assign them during the select and use them for your conditional tests.

  7. IF...ELSE (Transact-SQL) - SQL Server | Microsoft Learn

    Imposes conditions on the execution of a Transact-SQL statement. The Transact-SQL statement that follows an IF keyword and its condition is executed if the condition is satisfied: the …

  8. If/Then in table valued functionsSQLServerCentral Forums

    Jun 17, 2013 · CREATE FUNCTION dbo.TestFunction (@param1 int) RETURNS @test-2 TABLE(column1 int,column2 int) AS. BEGIN. IF @param1 = 1. BEGIN. INSERT INTO @test …

  9. Creating Conditional Statements in SQL Queries

    Dec 6, 2021 · IF(condition, True, False) from table; An IF statement simple introduces some condition and then returns a result based on whether the condition is true or false. When the …

  10. SQL | Conditional Expressions - GeeksforGeeks

    Dec 3, 2024 · The CASE, DECODE, COALESCE, GREATEST, IFNULL, and LEAST functions are some of the most useful conditional expressions in SQL, enabling us to handle multiple …

  11. Some results have been removed