User Profile

Collapse

Profile Sidebar

Collapse
Sri Ganesh
Sri Ganesh
Last Activity: Jun 28 '13, 02:08 PM
Joined: Jun 24 '13
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Sri Ganesh
    started a topic Sql Query

    Sql Query

    Hi,

    I have a table like this

    Code:
    CompanyName Addresstype Name  Addressline1       City     Country
    ABC         Billing     John  252,Green street   Chicago  USA
    ABC         Shipping    Jacob 152,Blue street    Chicago  USA
    ABC         Contact     Jerry 102,yellow street  Chicago  USA
    XXX         Billing     Rose  252,Green street   Newyork  USA
    XXX         Contact     Ajay  102,yellow street
    ...
    See more | Go to post
    Last edited by Rabbit; Jun 28 '13, 03:41 PM. Reason: Please use code tags when posting code or formatted data.

  • Sure Rabbit this is my solution...
    Code:
    WITH CTE AS
    (SELECT ROW_NUMBER() OVER(PARTITION BY COLUMN1 ORDER BY COLUMN1 ASC)AS ROW ,COLUMN1  FROM TABLE1)
    UPDATE CTE SET COLUMN1=A.COLUMN1 FROM TABLE2 A WHERE CTE.ROW=A.COLUMN1;

    Regards,
    Sri Ganesh
    See more | Go to post

    Leave a comment:


  • Hi use this qry....
    Code:
    SELECT A.DATE,A.NAME,A.COUNT1,B.DATE FROM TEMPTABLE A,TEMPTABLE B WHERE A.NAME=B.NAME AND A.DATE!=B.DATE AND 
    A.DATE<=B.DATE
    UNION ------------this union is to join same STARTDATE and ENDDATE
    SELECT DATE,NAME,COUNT1,DATE FROM TEMPTABLE WHERE NAME IN(
    SELECT NAME FROM
    (SELECT COUNT(NAME) AS COUNT1,NAME FROM(
    SELECT DISTINCT A.DATE AS STARTDATE,A.NAME,A.COUNT1,B.DATE AS ENDDATE
    ...
    See more | Go to post
    Last edited by Rabbit; Jun 25 '13, 03:28 PM. Reason: Please use code tags when posting code.

    Leave a comment:


  • Sri Ganesh
    replied to sql server cursor
    Hi,
    we cant create the cursors just we declare and deallocate it. It is a loop and not stored anywhere...

    Regards,
    Sri Ganesh
    See more | Go to post

    Leave a comment:


  • Hi
    Use this Query,


    Code:
    UPDATE SERVER1TABLE SET SERVER1TABLE.COLUMN1=B.COLUMN1,SERVER1TABLE.COLUMN2=B.COLUMN2
    FROM OPENDATASOURCE('SQLNCLI','DATA SOURCE=SECONDSERVERNAME;UID=XXXX;PWD=XXXXX').DATABASENAME.DBO.SERVER2TABLE AS B
    WHERE B.COLUMN1='XXXX' AND HRMS10EMPLOYEE.COLUMN1='XXXX'

    Regards,
    Sri Ganesh
    See more | Go to post
    Last edited by Rabbit; Jun 25 '13, 03:23 PM. Reason: Please use code tags when posting code.

    Leave a comment:


  • Hi Rabbit and ck9663 thanks for your replies i cant truncate the table if i want to add one more column in table1 means problem will be occurs, But i got a solution for this..

    Thanks
    Sri Ganesh
    See more | Go to post

    Leave a comment:


  • How to update single column values in sql server 2005

    Hi,

    I have a one column table like
    column1
    0
    0
    0
    0
    0


    And I have another one column table like
    column1
    1
    2
    3
    4
    5

    How to update table2 values into table1 value?
    When i am select table1 my output like this...
    Column1
    1
    2
    3
    4
    5
    Thanks
    See more | Go to post
No activity results to display
Show More
Working...