desikankannan
Posting Yak Master
152 Posts |
Posted - 2013-11-12 : 12:45:17
|
I try to alter the table and insert below code i have drop 5 columns and alter again the table. please help me to solve the issueIF NOT EXISTS ( SELECT * FROM syscolumns WHERE id = OBJECT_ID('DeathData') AND name IN('DonationTitle','SendDonationsTo','DonationAddress','DonationCity','DonationState','DonationZip' ))BEGINALTER TABLE DeathDataADD DonationTitle varchar(50) ,SendDonationsTo varchar(50),DonationAddress varchar(30),DonationCity varchar(30),DonationState varchar(30), DonationZip varchar(30)ENDIF EXISTS ( SELECT * FROM syscolumns WHERE id = OBJECT_ID('DeathData') AND name IN('DonationTitle','SendDonationsTo','DonationAddress','DonationCity','DonationState','DonationZip' ))BEGINinsert into tbldonations (donationstitle , donationsto,donaddress,doncity,donstate,donzip) select distinct DonationTitle , SendDonationsTo,DonationAddress,DonationCity,DonationState,DonationZip from DeathData where SendDonationsTo != '' END GOerrorMsg 207, Level 16, State 1, Line 9Invalid column name 'SendDonationsTo'.Msg 207, Level 16, State 1, Line 9Invalid column name 'DonationTitle'.Msg 207, Level 16, State 1, Line 9Invalid column name 'SendDonationsTo'.Msg 207, Level 16, State 1, Line 9Invalid column name 'DonationAddress'.Msg 207, Level 16, State 1, Line 9Invalid column name 'DonationCity'.Msg 207, Level 16, State 1, Line 9Invalid column name 'DonationState'.Msg 207, Level 16, State 1, Line 9Invalid column name 'DonationZipDesikankannan |
|
desikankannan
Posting Yak Master
152 Posts |
Posted - 2013-11-12 : 19:22:11
|
yes,if the run script first time , it works fine, if the run again second it throws the error, i don't want to show error messagequote: Originally posted by visakh16 Hmm..You're adding columns and immediately trying to populate data from it. WHat does that mean? you'll just have some NULL values getting inserted in tbldonations.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
Desikankannan |
|
|