About 888,000 results
Open links in new tab
  1. Function vs. Stored Procedure in SQL Server - Stack Overflow

    Jan 9, 2023 · Function: In SQL Server database, the functions are used to perform some actions and the action returns a result immediately. Functions are two types: System defined. User defined. Stored Procedures: In SQL Server, the stored procedures are stored in server and it can be return zero, single and multiple values. Stored Procedures are two types:

  2. Remove all spaces from a string in SQL Server - Stack Overflow

    Feb 19, 2022 · I know the original question was about simply replacing spaces, but should you need to replace ALL whitespace, you can use the TRANSLATE function (since Sql Server 2019) to convert a given list of characters to something easier to replace. Then wrap it with the REPLACE function.

  3. How Stuff and 'For Xml Path' work in SQL Server?

    Jul 4, 2015 · It works for MS SQL SERVER 2016 and later. DECLARE @agg VARCHAR(MAX) SELECT @agg = CONCAT(@agg + ',', name) FROM temp1 SELECT @agg When @agg is declared, its value is NULL. When the first row of the temp1 is fetched @agg is still NULL. @agg + ',' equals to NULL + ',' which results in NULL. See Microsoft Documentation

  4. How to implement LIMIT with SQL Server? - Stack Overflow

    This is almost a duplicate of a question I asked in October: Emulate MySQL LIMIT clause in Microsoft SQL Server 2000. If you're using Microsoft SQL Server 2000, there is no good solution. Most people have to resort to capturing the result of the query in a temporary table with a IDENTITY primary key.

  5. sql server - Execute WITH statement inside a function - Stack …

    Oct 31, 2012 · You don't need the semicolon before the WITH in a TABLE-VALUED FUNCTION. Especially considering that you cannot even have multi-statements in a TVF, there's no reason for a statement delimiter to be present. The correct form is CREATE FUNCTION (...) RETURNS TABLE AS RETURN <statement>

  6. sql server - Passing multiple values to a parameter of a function in ...

    Nov 3, 2015 · I just ran into this, and I used the CROSS APPLY solution from this post: SQL Server: run function for each row based on the provided row value. To use CROSS APPLY, you would need to first select your values, and then CROSS APPLY. I have not used the split function before, so I don't have the exact syntax, but if you use it something like:

  7. Use TO_DATE in SQL Server 2012 - Stack Overflow

    Nov 9, 2011 · The alternatives depend on what version of SQL Server you are using CAST() or CONVERT() may be used in any version. Starting with SQL Server 2012 onward one can use TRY_CAST() or TRY_CONVERT() .

  8. sql server - tsql returning a table from a function or store …

    Jun 30, 2011 · ALTER FUNCTION FnGetCompanyIdWithCategories() RETURNS @rtnTable TABLE ( -- columns returned by the function ID UNIQUEIDENTIFIER NOT NULL, Name nvarchar(255) NOT NULL ) AS BEGIN DECLARE @TempTable table (id uniqueidentifier, name nvarchar(255)....) insert into @myTable select from your stuff - …

  9. DECODE ( ) function in SQL Server - Stack Overflow

    Dec 8, 2016 · Create a function in SQL Server as below and replace the DECODE with dbo.DECODE CREATE FUNCTION DECODE(@CondField as nvarchar(100),@Criteria as nvarchar(100), @True Value as nvarchar(100), @FalseValue as nvarchar(100)) returns nvarchar(100) begin return case when @CondField = @Criteria then @TrueValue else @FalseValue end end

  10. sql server - Get the last day of the month in SQL - Stack Overflow

    May 1, 2009 · using sql server 2005, this works for me: select dateadd(dd,-1,dateadd(mm,datediff(mm,0,YOUR_DATE)+1,0)) Basically, you get the number of months from the beginning of (SQL Server) time for YOUR_DATE. Then add one to it to get the sequence number of the next month.

Refresh