SQL Server Equivalent of 'APPEND'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sachinkale123
    New Member
    • Jul 2007
    • 37

    SQL Server Equivalent of 'APPEND'

    I need sql Equivalent of Append statement...so
    can any one help in this...
    thanx
  • ilearneditonline
    Recognized Expert New Member
    • Jul 2007
    • 130

    #2
    What are you trying to accomplish? Your question is very vaque. If you are trying to concat 2 MS SQL fields, then you can just use...


    Code:
     SELECT field1 + ' ' + field2
    If the fields are not strings, then you will need to CAST or CONVERT them first.

    Code:
     SELECT CAST(field1 AS varchar(20)) + ' ' + field2
    if this isn't what you are looking for, please be more specific.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Originally posted by ilearneditonlin e
      What are you trying to accomplish? Your question is very vaque. If you are trying to concat 2 MS SQL fields, then you can just use...


      Code:
       SELECT field1 + ' ' + field2
      If the fields are not strings, then you will need to CAST or CONVERT them first.

      Code:
       SELECT CAST(field1 AS varchar(20)) + ' ' + field2
      if this isn't what you are looking for, please be more specific.

      if you're trying to APPEND records from tableA to tableB, that's an INSERT INTO command.

      Comment

      • sachinkale123
        New Member
        • Jul 2007
        • 37

        #4
        Hi,
        I m working on the project which was using MS Access but now i want to use SQL Server 2005.
        But there are some queries which are not understood by me, so please help me in converting those.
        Following is the query:

        SHAPE {select stlcode , SampleTypeCode, InNo,NoOfSample s,RecdDistrict, RecdT al,DtRecd , RecdFrom, RecdNameDesg, PrimaryInNo, MicroInNo, WaterInNo from SInward order by SampleTypeCode, InNo } AS ParentCMD APPEND
        ({select SampleType, InNo, SrNo, StlCode, AStlCode, SampleTakenDt, FarmerNm, FarAddVil, FarAddPost, FarAddDist, FarAddTal , FarAddPin, SurveyGrNo, ReprArea, LastSeason, LastSeasonCrop, NextSeason, NextSeasonCrop, NextSeasonCrop2 2, AgeOfTree, LandProfile, DepthFrom, DepthTo, WaterSource, CollectdBy, SampleAccepted, LabSampleNo, HCNumber, MicroLabSampleN o, WaterLabSampleN o from SDetails order by SrNo } AS ChildCMD RELATE SampleTypeCode TO SampleType, InNo to InNo, stlcode to stlcode) AS ChildCMD

        This query was previously written in MS Access and now I want it to be in SQL Server 2005, So please help me in solving this.
        Thanx

        Comment

        • ilearneditonline
          Recognized Expert New Member
          • Jul 2007
          • 130

          #5
          Originally posted by sachinkale123
          Hi,
          I m working on the project which was using MS Access but now i want to use SQL Server 2005.
          But there are some queries which are not understood by me, so please help me in converting those.
          Following is the query:
          Did you try the query? SHAPE is a ADO command and should work with SQL Server. I never used it myself, but I found this on the SQL Forums that it does work. SQL Forums.

          Comment

          • sachinkale123
            New Member
            • Jul 2007
            • 37

            #6
            Originally posted by ilearneditonlin e
            Did you try the query? SHAPE is a ADO command and should work with SQL Server. I never used it myself, but I found this on the SQL Forums that it does work. SQL Forums.

            I go the exact syntax but still it is giving me Error:

            SHAPE {SELECT [STLDATA].[dbo].[SInward].[StlCode] FROM [STLDATA].[dbo].[SInward]}
            APPEND ({ SELECT [SampleType], [StlCode], [SrNo] FROM [STLDATA].[dbo].[SDetails] }
            RELATE [SInward].[InNo] to [SDetails].[InNo])
            AS Sample

            Error Message:
            Msg 156, Level 15, State 1, Line 2
            Incorrect syntax near the keyword 'SELECT'.
            Msg 102, Level 15, State 1, Line 2
            Incorrect syntax near '}'.
            Msg 102, Level 15, State 1, Line 3
            Incorrect syntax near '}'.

            Comment

            Working...