tags:

views:

77

answers:

3

In SQL Server 2005, I'm trying to figure out How to fill up the following fields? Any kind of help will be highly appreciated..

INSERT INTO [Fisharoo].[dbo].[Accounts]
       ([FirstName]
       ,[LastName]
       ,[Email]
       ,[EmailVerified]
       ,[Zip]
       ,[Username]
       ,[Password]
       ,[BirthDate]
       ,[CreateDate]
       ,[LastUpdateDate]
       ,[TermID]
       ,[AgreedToTermsDate])
 VALUES
       (<FirstName, varchar(30),>
       ,<LastName, varchar(30),>
       ,<Email, varchar(150),>
       ,<EmailVerified, bit,>
       ,<Zip, varchar(15),>
       ,<Username, varchar(30),>
       ,<Password, varchar(50),>
       ,<BirthDate, smalldatetime,>
       ,<CreateDate, smalldatetime,>
       ,<LastUpdateDate, smalldatetime,>
       ,<TermID, int,>
       ,<AgreedToTermsDate, smalldatetime,>)
A: 

If you are using explicit values, you can just type them in. You can also use Select INTO syntax.

INSERT INTO [Fisharoo].[dbo].[Accounts]
       ([FirstName]
       ,[LastName]
       ,[Email]
       ,[EmailVerified]
       ,[Zip]
       ,[Username]
       ,[Password]
       ,[BirthDate]
       ,[CreateDate]
       ,[LastUpdateDate]
       ,[TermID]
       ,[AgreedToTermsDate])
 VALUES
       ('Bob'
       ,'Smith'
       ,'[email protected]'
       ,0
       ,'11111'
       ,'bsmith'
       ,'mylittlepony'
       ,'1/1/1950'
       ,'4/24/2010 11:23 PM'
       ,'4/24/2010 11:23 PM'
       ,3
       ,null)
Jeremy
Select into will create the table at the same time. If you try to select into a table that already exists it will generate an error.
TimothyAWiseman
I meant to say Insert INTO...Select http://msdn.microsoft.com/en-us/library/aa933206(SQL.80).aspx
Jeremy
A: 
INSERT INTO "Fisharoo" ("FirstName", "LastName", "Email", EmailVerified, "Zip", "Username", "Password", "BirthDate", "CreateDate", "LastUpdateDate", TermID, "AgreedToTermsDate")
VALUES ('Duck', 'Dummy', '[email protected]', 1, '12345', 'Ducky', 'test123', '2010-02-01', '2010-01-01', '2010-01-01', 3, '2010-01-01');
Acron
Really? My version of SQL Server 2005 really doesn't like the double quotes around the values. It thinks they're column names.
uncle brad
A: 

I'm not sure what you're really asking here. Is it this simple?

INSERT INTO [Fisharoo].[dbo].[Accounts]
   ([FirstName]
   ,[LastName]
   ,[Email]
   ,[EmailVerified]
   ,[Zip]
   ,[Username]
   ,[Password]
   ,[BirthDate]
   ,[CreateDate]
   ,[LastUpdateDate]
   ,[TermID]
   ,[AgreedToTermsDate])
 VALUES
   ('Bob'
   ,'Dole'
   ,'[email protected]'
   ,1
   ,'75454'
   ,'bdole'
   ,'topsecret'
   ,'07-22-1923'
   ,'04-24-2010'
   ,'04-24-2010 21:31'
   ,123
   ,'04-24-2010')

Is this a real table design or just an example? Because if it's real, please don't store the password as a varchar(50).

uncle brad
Thanks a lot...exactly what i was looking for...:D
littleBrain