C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

insert statement


Posted Date: 04 Jul 2008      Posted By: Ramesh Narayan      Member Level: Gold     Points: 1   Responses: 4





In a table test 3 columns contains i need to insert for only 2 columns using the below query method am unable to insert how can i insert for particular column

Table contains 3 columns:

These query not working:-
insert test(name1,fname,'XYZ')
select name1,fname from test

These query working:-
insert test(name1,fname,lname)
select name1,fname,lname from test





Responses

Author: VinothKumar    04 Jul 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi,
try this..

insert test(name1,fname)
select name1,fname from test

Hope this helps..
vino...



Author: Bharathi    04 Jul 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 3

because you have specified 'XYZ' which is like a value.

You should mention only the column names within the bracket and not the values. That is the reason the first query is not working and the second query does.



Author: Ashok    04 Jul 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 1

Use this query....
INSERT INTO test(name1,fname)VALUES('ABC','XYZ')
SELECT name1,fname FROM test

Please rate this post, if it is useful for you.

Thanks & Regards
Ashok



Author: Payal Jain    04 Jul 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 1

INSERT INTO test(name1,fname,'ABC' as <ur 3rd column name>)
SELECT name1,fname FROM test

HTH



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : insert statement
Previous : which is more adviseable for taking crush course, is it vb.net or c#.net
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use