Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    1

    Red face Unanswered: How to update Table using view

    Hello friends ,
    I have to update table lead_document_dtls having fields as
    Lead_no(int) Quote(bool) AWB(bool) PO(bool)

    i have created one view vwLeadDocumentDetails returning
    Lead_no(int) Quote(bool) AWB(bool) PO(bool) Doc_Type(varchar)

    Now if Doc_type of perticular Lead is 'PO' then value of PO should be "Y"
    otherwise shoud returns "N'.

    I have return One query as .


    update lead_document_dtls set
    Quote =
    case when dbo.vwLeadDocumentDetails.Total_Doc is not null and dbo.vwLeadDocumentDetails.Doc_type ='Quote'
    then 'Y'
    Else 'N'
    End
    ,
    AWB=
    case when dbo.vwLeadDocumentDetails.Total_Doc is not null and dbo.vwLeadDocumentDetails.Doc_type ='Awb'
    then 'Y'
    Else 'N'
    End
    ,

    PO=
    case when vwLeadDocumentDetails.Total_Doc is not null and vwLeadDocumentDetails.Doc_type ='PO'
    then 'Y'
    Else 'N'
    End

    where Lead_document_dtls.lead_No=vwLeadDocumentDetails.L ead_no



    but it give error as

    The column prefix 'dbo.vwLeadDocumentDetails' does not match with a table name or alias name used in the query.

    Please help me , it's argent.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    You forgot
    FROM vwLeadDocumentDetails
    where Lead_document_dtls.lead_No=vwLeadDocumentDetails.L ead_no
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •