Does REPLACE function in SQL Server accept input from a table for 'string_pattern' parameter?

后端 未结 5 1364
清酒与你
清酒与你 2021-01-25 08:55

I\'m still learning my ropes with SQL Server and maybe this question sounds very naive/ridiculous. Please bear with me on this. :)

I saw a function in SQL Server defined

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-25 09:23

    In general, yes you can use the value from a column for any place in SQL Server's syntax where a value is expected (as opposed to where a name is expected, such as the first argument to DATEPART).

    However, this is broken code - it appears to assume that each row will be evaluated in sequence and each row will be evaluated using values produced from previous rows. However, SQL Server only guarantees to perform one assignment (for the "last" row - however, with no ORDER BY clause, "last" is ill-defined):

    If the SELECT statement returns more than one value, the variable is assigned the last value that is returned.

    Whether it may appear to work is no guarantee that more than a single assignment will actually take place.

提交回复
热议问题