Tag Info

New answers tagged


SELECT DISTINCT a.id, a.etc FROM years y JOIN activitymapper am ON (y.targetyearid = am.targetyearid) JOIN activity a ON (a.id = am.activityid) WHERE y.targetyearname IN ('Year1', 'Year2') Should do it. We're going from years to activity through activitymapper, selecting each activity only once (DISTINCT).


If you are creating comma delimited files, you should probably use double quote and comma delimited. Excel can read the files as is, and you are less likely to have the data in the database mess up the format. I have also used the tilde ~ as a delimiter. It doesn't get used very often so it tends to be safe to use.


The statement terminator in SQL Server is a semi-colon ;. http://msdn.microsoft.com/en-us/library/ms177563.aspx As queries cannot contain a semi-colon, except as the last character to identify the end of the query, this should be enough for you to separate out each statement.

Top 50 recent answers are included