Posts Tagged ‘SQL Server 2005’

SQL Server – Padding 0 (another way)

SELECT LEFT(PREFIX + REPLICATE(@PADSTRING, 10), 10) + ISNULL(SUFFIX,”)

More »

HowTo Convert Table Values to Comma-Delimited String

  Original Post here The function below demonstrates a technique how to convert table values into comma-delimited string with one query. ALTER FUNCTION F_GET_STR (@p_order_id int) RETURNS varchar(1000) AS BEGIN DECLARE @p_str VARCHAR(1000) SET @p_str = ” SELECT @p_str = @p_str + ‘,’ + CAST(productid AS VARCHAR(6)) FROM [order details] WHERE orderid = @p_order_id RETURN [...]

More »