Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2008-01-12 : 05:12:00
|
| I have writen a small program in a Query window that runs fine if I hilight and run small chuncks. (I have listed the statements with out the clauses so it is more easly viewed here.)The problem is if I simply execute the Query window I get massive errors that don’t make sence. I am guessing I need some GO and BEGIN/END statements? But I don’t know where I should use them.I would really appreciate a few pointers so I can just run the Query window.drop table SourceFiledrop table ReferenceFileSELECT TOP INTO SourceFile FROM SELECT TOP INTO ReferenceFile FROM -- test dataINSERT ReferenceFile (AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip)values ()INSERT SourceFile (AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip)values (22)-- test datadrop table MATCHTESTSELECT TOP 1 AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip INTO MATCHTEST FROM AddressCleaned_npidata_20050523_20071112DELETE MATCHTESTALTER TABLE MATCHTEST ADD REF_ML VARCHAR(2)INSERT MATCHTEST () SELECT FROM ReferenceFile r inner join SourceFile s on s.New_Last_Name = r.New_Last_Name select * from MATCHTEST |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-12 : 06:09:50
|
quote: Originally posted by kirknew2SQL I have writen a small program in a Query window that runs fine if I hilight and run small chuncks. (I have listed the statements with out the clauses so it is more easly viewed here.)The problem is if I simply execute the Query window I get massive errors that don’t make sence. I am guessing I need some GO and BEGIN/END statements? But I don’t know where I should use them.I would really appreciate a few pointers so I can just run the Query window.drop table SourceFiledrop table ReferenceFileGOSELECT TOP INTO SourceFile FROM SELECT TOP INTO ReferenceFile FROM -- test dataINSERT ReferenceFile (AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip)values ()INSERT SourceFile (AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip)values (22)-- test datadrop table MATCHTESTGOSELECT TOP 1 AddressCleanedPK, New_First_Name, New_Last_Name, New_Address, Phone, Zip INTO MATCHTEST FROM AddressCleaned_npidata_20050523_20071112DELETE FROM MATCHTESTALTER TABLE MATCHTEST ADD REF_ML VARCHAR(2)GOINSERT MATCHTEST () SELECT FROM ReferenceFile r inner join SourceFile s on s.New_Last_Name = r.New_Last_Name select * from MATCHTEST
Try this modified query |
 |
|
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2008-01-12 : 11:43:18
|
| That works thank you. |
 |
|
|
kirknew2SQL
Posting Yak Master
194 Posts |
Posted - 2008-01-12 : 14:38:41
|
| Oh yes. One last thing... What are the guidlines I should use to determin where to place the GO's? |
 |
|
|
|
|
|
|
|