Archive for the ‘MS SQL 2005’ Category

select stud_id , group_concat(paper_id) as i from tb
group by id

Original Table:
stud_id paper_id
1 1
1 2
1 3
1 4
2 2
2 3
3 1
4 2

Output:
stud_id paper_id
1 1,2,3,4
2 2,3
3 1
4 2

Advertisements

SELECT id as student_id,
student_code,
‘Present’ AS attendance_legend_name,
first_name
FROM dbo.ad_student_m

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

CREATE FUNCTION [GetAmount]
(

@Amount decimal,
@Interest decimal,
@Tax decimal
)
RETURNS Decimal(10,2)
AS

BEGIN
DECLARE @TAmount decimal(10,2);
set @TAmount = @Amount + @Interest + @ServiceTax

RETURN @TAmount;
END

SELECT DATEDIFF(day, DATE_MODIFIED, GETDATE()) AS no_of_days FROM EDITVIEWS_FIELDS

CONVERT(nvarchar(8), dbo.fs_deposit_m.date_of_deposition, 112) BETWEEN 20090201 AND 20090302