Results 1 to 3 of 3

Thread: insert

  1. #1
    Join Date
    May 2003
    Posts
    40

    Unanswered: insert

    Folks

    In the below insert stmt datStarted, datPlaced and datExpDate are three
    columns in the table Policies. Is there any way that we can insert the column values
    in place of datOrigEffective , datEffective and datRenewal.

    the error I m getting is : datStarted is a column name and is not allowed. Only constants
    expressions , variables are allowed.


    insert into Policies(strPolicyNumber,strStatus,datOrigEffectiv e,
    datEffective,datRenewal,curPremium,lngAgentID,blnF orced) values(@PolicyNum,'IF', datStarted,datPlaced,datExpDate,@Premium,@AgentID, @bForced)



    Thks

  2. #2
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    Drop the Values bit:

    INSERT INTO Policies(strPolicyNumber,strStatus,datOrigEffectiv e,datEffective,datRenewal,curPremium,lngAgentID,bl nForced)
    SELECT @PolicyNum,'IF',datStarted,datPlaced,datExpDate,@P remium,@AgentID,
    @bForced
    -bpd

  3. #3
    Join Date
    Aug 2003
    Location
    Andover, MA
    Posts
    256
    It would actually also be good form (not required) to use field name alias:

    INSERT INTO Policies (strPolicyNumber, strStatus, datOrigEffective, datEffective, datRenewal, curPremium, lngAgentID, blnForced)
    SELECT @PolicyNum AS strPolicyNumber ,'IF' AS strStatus, datStarted AS datOrigEffective, datPlaced AS dateEffective, datExpDate AS datRenewal, @Premium curPremium, @AgentID AS lngAgentID, @bForced AS blnForced
    FROM Policies

    (and I forgot the FROM bit!!)
    -bpd

Posting Permissions

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