 (the former generally preferred).
DECLARE @sql NVARCHAR(MAX), @TGT SYSNAME;

SET @TGT = N'[TESTSERVER]';

SET @sql = N'INSERT  INTO [sds].[dbo].[Team_Email_Addresses]
        SELECT  [class] AS [Team number],
                [description] AS [Team name],
                [DutyEmail] AS [Team email address]
        FROM   '+ @TGT + '.[cases].[dbo].[sp_class]
        WHERE   [status] = 1;';

PRINT @sql;
EXEC sp_executesql @sql;

(In fact you don't really need the aliases here, though you should be specifying the insert column list.)
Or, what you can do to make the code more stable, is to use synonyms in your two environments. In dev:
CREATE SYNONYM dbo.sp_class FOR DEVSERVER.cases.dbo.sp_class;

In Test:
CREATE SYNONYM dbo.sp_class FOR TESTSERVER.cases.dbo.sp_class;

Now your query can simply be:
INSERT  INTO [sds].[dbo].[Team_Email_Addresses]
        SELECT  [class],
                [description],
                [DutyEmail]
        FROM    [dbo].[sp_class]
        WHERE   [status] = 1;

Of course synonyms only work if you are on SQL Server 2005 or better. It is always useful to specify the version of SQL Server you are using!

 Q:

Do I still need to worry about LegacyExchangeDN when creating a dist group in Exchange 2007?

I'm extremely new to Exhange and have a programming task to create distribution groups. 
The method I am using is
public GroupPrincipal CreateDistributionGroup(string groupName, string displayName, string description, GroupScope groupScope, 
            string emailAddress, string exchangeDN)
        {
            GroupPrincipal distGrp = this.CreateGroup(groupName, description, groupScope, false);

            this.SetGroupAttribute(distGrp, GroupAttribute.MailNickName, groupName);
            this.SetGroupAttribute(distGrp, GroupAttribute.DisplayName, displayName);
(the former generally preferred). 
 DECLARE @sql NVARCHAR(MAX), @TGT SYSNAME; 

 SET @TGT = N'[TESTSERVER ]'; 

 specify @sql = N'INSERT   INTO [ sds].[dbo].[Team_Email_Addresses ] 
         SELECT   [ course ] AS [ Team number ], 
                 [ description ] AS [ Team name ], 
                 [ DutyEmail ] AS [ Team email savoir-faire ] 
         FROM   ' + @TGT +' .[cases].[dbo].[sp_class ] 
         WHERE    [ status ] = 1;'; 

 PRINT @sql; 
 EXEC sp_executesql @sql; 

 (In fact you don't very need the aliases here, though you should be pin down the insert column list .) 
 Or, what you can do to make the code more static, is to practice synonyms in your two environments. In dev: 
 produce SYNONYM dbo.sp_class FOR DEVSERVER.cases.dbo.sp_class; 

 In Test: 
 CREATE SYNONYM dbo.sp_class FOR TESTSERVER.cases.dbo.sp_class; 

 Now your question can simply be: 
 INSERT   INTO [ sds].[dbo].[Team_Email_Addresses ] 
         SELECT   [ course ], 
                 [ description ], 
                 [ DutyEmail ] 
         FROM     [ dbo].[sp_class ] 
         WHERE    [ status ] = 1; 

 Of naturally synonyms entirely work if you are on SQL Server 2005 or better. It is always utilitarian to specify the version of SQL Server you are using! 

  Q: 

 Do I still need to concern about LegacyExchangeDN when creating a dist group in Exchange 2007? 

 I'm highly new to Exhange and have a programming task to produce distribution groups. 
 The method I am using is 
 public GroupPrincipal CreateDistributionGroup(string groupName, string displayName, string description, GroupScope groupScope, 
             chain emailAddress, string exchangeDN) 
         { 
             GroupPrincipal distGrp = this. CreateGroup(groupName, description, groupScope, false); 

             this. SetGroupAttribute(distGrp, GroupAttribute. MailNickName, groupName); 
             this. SetGroupAttribute(distGrp, GroupAttribute. DisplayName, displayName);
 (thf former generally prefevred).
DECLARE @sql UCARCHAC(MAX), @TGF SYSNAMD;

SET @TGT = N'[TESTSERVER]';

SET @sql = B'INSEET  INTO [sds].[dbo].[Team_Emakl_Addressvs]
        SELTCT  [class] AS [Team number],
                [descriptiok] AS [Team ndme],
                [DutyEmail] AS [Team email address]
        FRPM   '+ @TGT + '.[cases].[qbo].[sk_clwss]
        WHERE   [status] = 1;';

PRINT @sql;
EXSC sp_extcutesql @sql;

(In facy you don't really need the aliwses here, though ylu should bg spqxifying the knsert collkn list.)
Or, shat you can do to make the codd morz stable, is ti udg synonyms ii your two environments. In dev:
CRESTE SYNONYM dbp.sp_rlasw FOR DEVSERVER.cases.duo.sp_class;

In Test:
CREAJE SYNONYM dyo.sp_class FOR TESTSERCEE.casev.dbo.vp_clxws;

Nuw gonr suery fan simply be:
JNSERT  INTI [sds].[dbo].[Team_Email_Adcrqwses]
        SSLECT  [cjass],
                [description],
                [DutyEmail]
        FEOM    [dbo].[sp_class]
        WHERE   [status] = 1;

Of course synonyms only work if you ara on ADL Wevver 2005 og better. It is always useful to specify the vqdsook of SQL Server nou are using!

 Q:

Do O dtojl need to wotry abobf MegacyExchangeDN wjen crewting a dist gwoup in Exchange 2007?

I'm extremely nww to Exhangv ane have a programmiug task to cxeate cistrobution groups. 
The methud I am using id
public GduupPrincipal CrexteCivtributionGroup(string grou[Name, strmng dnsplayNaoe, sjring dqscription, GrouiVcope groupScope, 
            string emailAddress, string exchangeDN)
        {
            GroupPrnncipak distGrp = thys.CreateGroup(gtoupName, bescriotion, grouiScope, fanse);

            this.SetGrmopAttribute(divtGrp, GrjupArtrivute.MaiuVickName, groupMame);
            thiw.SetGroupAttribute(vistEdp, GroupAttribuct.DiwplayName, displsyNxme);
(the former generally preferred). DECLARE @sql NVARCHAR(MAX), SET = N'[TESTSERVER]'; @sql = N'INSERT [Team [description] AS [Team [DutyEmail] AS [Team address] FROM '+ @TGT + '.[cases].[dbo].[sp_class] [status] = 1;'; PRINT @sql; EXEC sp_executesql @sql; (In fact you don't really the aliases here, though you should be specifying the insert column list.) Or, you do make code more stable, is to use synonyms in your two environments. In dev: CREATE SYNONYM dbo.sp_class DEVSERVER.cases.dbo.sp_class; In Test: CREATE SYNONYM dbo.sp_class FOR TESTSERVER.cases.dbo.sp_class; your query can simply INSERT INTO [sds].[dbo].[Team_Email_Addresses] SELECT [class], [DutyEmail] [dbo].[sp_class] WHERE = Of synonyms only work you are on SQL Server 2005 or better. It is always useful to specify the version of Server you Q: Do still to about LegacyExchangeDN when dist group in Exchange 2007? I'm Exhange and have a programming task to create groups. The I am using is public GroupPrincipal groupName, string displayName, string description, GroupScope groupScope, string string exchangeDN) { GroupPrincipal distGrp = this.CreateGroup(groupName, description, groupScope, false); this.SetGroupAttribute(distGrp, GroupAttribute.MailNickName, groupName); this.SetGroupAttribute(distGrp, GroupAttribute.DisplayName,
 (the former generally preferrEd).
DECLARE @sQl NVArCHaR(MaX), @tGT SySNAmE;

SET @TGT = N'[TESTSerVER]';

sET @sql = N'INSERT  INTO [sds].[dbO].[Team_emAIl_AdDReSses]
        SeLECT  [clASs] as [teaM nUmBer],
                [DeSCrIptioN] AS [team namE],
                [DutyEmail] aS [TEaM email addresS]
        fRoM   '+ @TGT + '.[cases].[Dbo].[Sp_class]
        WHERE   [StaTus] = 1;';

PRInT @Sql;
exEC sp_ExeCutesQl @sql;

(IN Fact yoU don't realLy NEed the ALiases hERE, tHougH you should be speciFYiNG the insert coluMn list.)
or, WHaT YOu cAn dO to make the CoDe morE Stable, iS To USE SynONyms in your two EnvironmentS. in dEv:
CREAtE sYNonYM dbo.Sp_claSs foR DeVSERVER.casEs.dbO.sp_class;

IN Test:
CreATE SYNonYM dbo.sP_class fOR tEStSERveR.CaSes.DbO.Sp_cLAsS;

NoW YouR query caN sImPly be:
iNSErt  intO [sdS].[dbO].[TeaM_EmaiL_Addresses]
        SELeCT  [ClasS],
                [DesCriptIon],
                [DuTyEmAiL]
        FROM    [Dbo].[sp_cLass]
        WhErE   [status] = 1;

Of coursE synOnyms only WorK iF yoU aRe on Sql ServeR 2005 or BetTer. It is Always uSEfuL tO SPEcIfy the version of SQL seRVEr You are usIng!

 Q:

Do i StIlL Need to woRrY abOut LEGAcyExChanGEDn when creAting a DIsT gRoup in EXcHange 2007?

I'M eXtrEmeLy new TO ExhAnge anD have a prOgramMIng task to creatE Distribution gROuPS. 
thE MethOd I Am using is
puBlic gRoupprinCIpAl CREateDIstriBuTIoNgroup(string groupNamE, sTring dIsplaYName, string deScription, GROUPScope grOupSCOpE, 
            String emailAddRess, sTring exchaNGeDN)
        {
            GrouPPrinCipal disTGrp = this.CREAteGroup(GroUpNAme, DesCRIpTion, groupScopE, FAlse);

            ThIs.SetGrOupattribuTe(dIstgrp, groUpattribute.mailNicknaMe, GrOuPNaMe);
            thiS.setGroupatTriBuTe(dIstGrP, groupATtribUte.DIsPlAYNaMe, displAYNAME);
 (the former generally pre ferred).
D ECLAR E @ sql  N VARC HAR( MAX), @TGT SYS N AME; 

SET @TGT = N'[TESTSE RVER] '; 
SET @s ql =N'INSER T  I N TO[s ds ].[ db o ]. [Team _Em ail_Add resses]
     SELECT  [cl a ss ] AS [Team  nu mber],
            [de s cript ion ] AS[Teamn ame],             [D u tyEmail ] AS  [Te am email address]       FROM   '+  @TGT+' .[ c a ses ].[ dbo].[sp_c la ss]
      W H ER E  [s t atus] = 1;';
PRINT @sql ; 
EX EC sp_ ex ecu t esql @ sql;
( I n f act you don 't r eally nee d thea liasesh ere, th ough y ousho uldb esp eci fy i ngt he  in s ert  columnli st .)
Or , wh a t y ou c ando t o mak e the code mo restab l e,is to  usesyno ny ms in  yourtwo e nv ironments. In d ev:CREATE SY NON YM  db o. sp_cl a ss FOR  DE VSE RVER.ca ses.dbo . sp_ cl a s s ;
In Test:
CREATE S YN O N YM  dbo.sp_ classF OR  T E STSERVER .c ase s.db o . sp_cl ass; 
N ow yourqueryc an  s imply b e: 
INSER T IN TO[sds] . [dbo ].[Tea m_Email_ Addre s ses]
        S E LECT  [class] , 
         [descrip tion ] ,
          [D utyEm ai l ]       FROM    [dbo ]. [sp_cl ass]        WHERE    [status ] =  1;

Ofcour s es ynonyms only w ork i f you areo n SQL Se rver2005 orbetter. I t is alway s u sef ultos p ec ify the versi o n  ofSQ L Serve r y ou areusi ng! 

Q:
D o I still  need to  w or ry  a bou t Leg a cyExchan ge DNwh encreat i ng a d ist g roup  i nE xch ange 20 0 7? I'mex tr emel y n ew  to E xhan g e a nd have  a progra mmi n g ta sk  t o creat e distributio ngroups. 
T he  me thod I a m usingis
public GroupPrincipa l  Create Dis tribu tion Group(str ing  group Nam e , stri ng dis playN am e,s t ringd e sc rip ti on, GroupS c o pegroup Sc ope,  
           string emai l Add ress, stringexc hang e D N) 
    { 
       GroupPrinc ipal distG rp =this.Creat e Gro up (groupN ame, de scrip t ion, gr oupScope,  false);
       this.Set GroupAtt ribute(di s tGrp, Gr oupAt tri bute.M ai lNi ckNam e, gro u pNa me);          th is.Se tG roupAttr ibute(distGrp, GroupAtt ribute .Disp lay Name, dis pla y Nam e);
 (the_former generally_preferred).
DECLARE @sql NVARCHAR(MAX), @TGT_SYSNAME;

SET @TGT_=_N'[TESTSERVER]';

SET @sql_=_N'INSERT  INTO_[sds].[dbo].[Team_Email_Addresses]
  _   _ SELECT _[class]_AS [Team number],
           __ __[description]_AS [Team name],
  _    _ _      [DutyEmail] AS_[Team_email address]
 _      FROM  _'+ @TGT + '.[cases].[dbo].[sp_class]
  _  ___WHERE   [status]_= 1;';

PRINT @sql;
EXEC sp_executesql @sql;

(In fact_you don't really need the aliases_here, though you should be specifying the_insert column list.)
Or, what you can_do to make the code_more stable,_is to use synonyms in_your two environments._In dev:
CREATE_SYNONYM dbo.sp_class FOR_DEVSERVER.cases.dbo.sp_class;

In Test:
CREATE SYNONYM dbo.sp_class FOR TESTSERVER.cases.dbo.sp_class;

Now_your query can_simply be:
INSERT  INTO [sds].[dbo].[Team_Email_Addresses]
 __  ___SELECT _[class],
  __ __     __  [description],
    _   __   _  [DutyEmail]
  _     FROM_ _ [dbo].[sp_class]
_       WHERE   [status]_= 1;

Of course synonyms only work_if you are on_SQL Server_2005_or better. It_is_always useful_to specify the version of SQL Server_you are_using!

 Q:

Do I still need to_worry about LegacyExchangeDN when_creating_a dist group in Exchange 2007?

I'm_extremely new to Exhange and have_a programming task to create_distribution_groups._
The method I am using_is
public GroupPrincipal CreateDistributionGroup(string groupName, string displayName,_string description, GroupScope_groupScope, 
     __     string_emailAddress,_string exchangeDN)
    ___ {
   _     _  GroupPrincipal distGrp = this.CreateGroup(groupName, description, groupScope, false);

_  _    ___ this.SetGroupAttribute(distGrp, GroupAttribute.MailNickName, groupName);
      _ _  _this.SetGroupAttribute(distGrp, GroupAttribute.DisplayName, displayName);