Monday, January 24, 2011

Create Table Variable, Insert Records, and Change one Row

 Use BLOG
  
 GO
  
  declare @Fields table
  
      (
  
      Name varchar (25),
  
      County varchar (25),
  
      Crop varchar (25)
  
      );
  
 Insert into @Fields
  
 (Name, County, Crop)
  
 values
  
 ('Droske Quarter', 'Pembina', 'Potatoes');
  
 Insert into @Fields
  
 (Name, County, Crop)
  
 values
  
 ('Nash Quarter', 'Walsh', 'Wheat');
  
 Insert into @Fields
  
 (Name, County, Crop)
  
 values
  
 ('Cambell Half Section', 'Pembina', 'Navy Beans');
  
 Insert into @Fields
  
 (Name, County, Crop)
  
 values
  
 ('Home 90', 'Pembina', 'Sugar Beets')
  
 Insert into @Fields
  
 (Name, County, Crop)
  
 values
  
 ('Lysengen Quarter', 'Pembina', 'Potatoes')
  
 select *
  
 from @Fields
  
 delete from @Fields
  
 where Name='Lysengen Quarter'
  
 select *
  
 from @Fields
  
 update @Fields
  
 set Crop = 'Wheat'
  
 where Name = 'Cambell Half Section'
  
 select *
  
 from @Fields  

No comments:

Post a Comment