Need help

  • I have two tables

    Table A

    Table B

    Both tables have the following four columns

    School Code

    School name

    Grade

    Year

    i want to insert values from table B into table A

    Table B has the following values in its columns

    School Code School name Grade Year

    24 abc 2 99

    25 xyz 3 99

    what i want is when i insert the above values from table B INTO table A it should be like below

    School Code School name Grade Year

    0024 abc 2 1999

    0025 xyz 3 1999

  • This really isn't difficult. What have you tried so far?

    John

  • can you guide me how to do this i am short of time and have no time to research .appreciate your help

  • Look up STUFF in BOL. Are the years all prior to 2000?


  • What are the data types for these fields? Might not be possible.

  • Also, how are the tables defined (please post the DDL for the tables)?

  • And if we do end up doing this for you (again), let us know what grade we got, even though "it's not homework".

    Actually, I take it back. I can't speak for anyone else, but you do this repeatedly, and if it's truly not homework (which I don't believe for a minute), then your unwillingness to put out the smallest bit of effort to learn the skills needed for your job should result in you being fired. So, I (again, speaking only for myself) am no longer going to help you in any way, shape, or form, unless you show that you've put at least some effort into resolving it via BOL.

    I think it's time for you to man up a bit.

  • David, Actually well put. I just am curious if what he wants to do is doable.

  • i dont know why you guys created these forums if you dont want to help only bigh mouths .Any way i will get it myself you guys can only disgrace and you should be critic professor not developers,i think if you something you dont loose if you tell

  • Actually, all we are asking is that you try to solve your problems first. If you are having difficulties, show us what you have done and we will gladly help you from there. Every post you have created asking for help, you never show us what you have done or tried. It is like you expect us (members of SSC) to do your work (home or job) for you.

    We can give you the fish and feed you for a day, or we can teach you to fish, in which case you can feed yourself for a lifetime. We'd prefer to teach you to fish.

    😎

  • Best;

    by simply clicking on your name and looking over your previous posts, it's obvious that the moment you encounter a question, you post it here first without ever attempting to look at it yourself.

    By reading the context of the posts, it's also obvious you do not TRY the suggested solutions that are offered to you before commenting on them either. Yuo consistantly offer incomplete questions, and want users to second guess and backfill your requirements, and provide a complete solution to your question. That's not what the forums main purpose is...the purpose is more towards HELPING, not DOING it for you.

    There is a HUGE difference between asking a blank newbie statement on how to do something,(without ever checking BOL or Google) and saying "i tried this , expected this and it didn't work as expected, can someone help"

    Users here LOVE to help those who help themselves.

    We tend to nudge newbies to learn to do a bit of research on their own before throwing up their hands.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • ok that is a good reply and i guess i understand wht is your point of view i will make sure i will follow it.

    thanks

  • Best (10/19/2007)


    I have two tables

    Table A

    Table B

    Both tables have the following four columns

    School Code

    School name

    Grade

    Year

    i want to insert values from table B into table A

    Table B has the following values in its columns

    School Code School name Grade Year

    24 abc 2 99

    25 xyz 3 99

    what i want is when i insert the above values from table B INTO table A it should be like below

    School Code School name Grade Year

    0024 abc 2 1999

    0025 xyz 3 1999

    Hello Best,

    It may not be the intension of the members to criticise something or disgrace someone but they are here to help you out with a better solution and advise if the complete information is available.

    Like one of the members request you for the datatype of the column and one member asked as to if all the years are prior to 2000.

    If you have the datatype of last column as varchar or something that supports string

    you can straight away append '19' to it by

    INSERT INTO TableA

    SELECT [School Code ] ,[School name ] ,[Grade] , '19' + Year from TableB

    Assuming all years are prior to 2000

    And if the datatype is int or some numeric datatype then

    INSERT INTO TableA

    SELECT [School Code ] ,[School name ] ,[Grade] , CAST('19'+ CAST(Year AS VARCHAR(2)) AS INT)

    from TableB

    Let me know if you have any questions.

    Prasad Bhogadi
    www.inforaise.com

  • thanks for the help but from now i will try to help myself and find the solution and if i dont i will let you guys wht i have done so far before i post my question

  • you will still need to use STUFF to pad the school code with 0's in front.


Viewing 15 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic. Login to reply