Skip to main content
Commonmark migration
Source Link

##Function that returns a long list of values##

Function that returns a long list of values

##Function that returns a seller's ID##

Function that returns a seller's ID

##Function that returns an image value from database##

Function that returns an image value from database

##Function that returns a long list of values##

##Function that returns a seller's ID##

##Function that returns an image value from database##

Function that returns a long list of values

Function that returns a seller's ID

Function that returns an image value from database

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I've currently got a MSSQL stored procedure that uses multiple SQL functions to achieve a number of returns. Now I've been told about using sets rather than functions as it creates " bad code smell of a DBA who is not yet thinking in sets" Original LinkOriginal Link

I've currently got a MSSQL stored procedure that uses multiple SQL functions to achieve a number of returns. Now I've been told about using sets rather than functions as it creates " bad code smell of a DBA who is not yet thinking in sets" Original Link

I've currently got a MSSQL stored procedure that uses multiple SQL functions to achieve a number of returns. Now I've been told about using sets rather than functions as it creates " bad code smell of a DBA who is not yet thinking in sets" Original Link

added requested function
Source Link

##Function that returns an image value from database##

CREATE FUNCTION dbo.funcDefaultImage
(
    @PropertyId INT,
    @Position INT
)

RETURNS VARCHAR(50)

AS
BEGIN
    DECLARE @IMAGE VARCHAR(50)
    
    SELECT @IMAGE = T.image
    FROM (
        SELECT
            ROW_NUMBER() OVER (ORDER BY weight DESC) AS [rownum],
            PROPERTYGALLERY.image
        FROM
            PROPERTYGALLERY
        WHERE
            PROPERTYGALLERY.PropertyId = @PropertyId
    ) T
    WHERE
        rownum = @Position

    RETURN @IMAGE
END

Result may look like - property_0001.png

##Function that returns an image value from database##

CREATE FUNCTION dbo.funcDefaultImage
(
    @PropertyId INT,
    @Position INT
)

RETURNS VARCHAR(50)

AS
BEGIN
    DECLARE @IMAGE VARCHAR(50)
    
    SELECT @IMAGE = T.image
    FROM (
        SELECT
            ROW_NUMBER() OVER (ORDER BY weight DESC) AS [rownum],
            PROPERTYGALLERY.image
        FROM
            PROPERTYGALLERY
        WHERE
            PROPERTYGALLERY.PropertyId = @PropertyId
    ) T
    WHERE
        rownum = @Position

    RETURN @IMAGE
END

Result may look like - property_0001.png

edited tags
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473
Loading
Source Link
Loading