0

I would like to know is there a way to insert values to the same column without updating the same value.

This is my table structure

Column Name Data Type Allow Nulls
----------- --------- ------------
Expiry Date Date       No

Now I would like to insert multiple date values in the Expiry Date. So how do I do that?

So that my output should be as follows:

Expiry Date

23/3/2014,23/4/2014,23/5/2015

This is my insert Statement

cmd.CommandText = "INSERT INTO Customers (UserID, Validity, Amount, RegisteredDate, 
ExpiryDate, FirstName, LastName, Address, State, City, Phone, Mobile, Email) 
VALUES(@UserID,@Validity,@Amount,@RegisteredDate,@ExpiryDate,@FirstName,@LastName,
@Address,@State,@City,@Phone,@Mobile,@Email)"

This is my Update Statement:

cmd.CommandText = "UPDATE Customers SET  UserID = @UserID, Validity = @Validity, 
Amount = @Amount, RegisteredDate = @RegisteredDate, ExpiryDate = @ExpiryDate,
FirstName   = @FirstName, LastName = @LastName , Address = @Address, State = @State, 
City = @City, Phone = @Phone, Mobile= @Mobile, Email = @Email WHERE UserID = @UserID"
1
  • you can't date data type can only hold date data. comma seperated strings are not valid dates. Might be possible if you're doing tables within tables; but i never saw the point in this yet. Commented Mar 23, 2013 at 12:25

1 Answer 1

1

If your ExpiryDate is defined in the database as a date field then the answer is you can't do that. However, if it defined as a string (which it should never be) then you can just concatenate the multiple expiry dates and store it as you would any other string. But I don't see how multiple expiry dates makes sense. But if, for some reason that isn't obvious multiple dates are valid and you want them stored as dates then you could define a separate table of expiry dates and store an ExpiryDateID in the first table and have a one-to-many relationship between the existing table and the new one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.