March 5, 2010 at 1:14 am
hi i'm new to sql server 2005 and to database in general i have 2 tables one is customers that has IP,Fname,Lname,Telephone,Email,Location,TypeofConnection,StartDate and the second table is stopped and has IP,Fname,Lname,Telephone,Email,Location,TypeofConnection,StartDate,StoppedDate.
i want to copy data from customer table to stopped table where IP and stoppedDate are taken from textboxes. i worte this Insert into statement but i'm getting error this is the statement that i wrote:
"INSERT INTO stopped (IP, Fname, Lname, Telephone,Email, Location, TypeofConnection, StartDate, StoppedDate) SELECT IP, Fname, Lname, Telephone,Email, Location, TypeofConnection, StartDate from customers where IP = '" & TextBox1.Text & "' AND StoppedDate = '" & TextBox2.Text & "';"
and the error is :
Number of query values and destination fields are not the same.
how can i solve this problem.
March 5, 2010 at 2:58 am
remove the StoppedDate column from the query and make sure that the column is nullable otherwise you've to specify a default value for the same.
after this run your query after removing the said column, your query will succeed.
enJoy
Regards,
Sarabpreet Singh 😎
Sarabpreet.com
SQLChamp.com
Twitter: @Sarab_SQLGeek
March 6, 2010 at 12:38 am
i know that but i want to do it that way isn't any other way to do it?
March 6, 2010 at 4:28 am
Why don't you like Sarab's answer ?
The way you have it now, you're telling SQL to insert into Stopped Date, but you're not telling SQL what to put in that field. You either have to tell it a value, or use a default.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply