Insert Bln into new column?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Insert Bln into new column?

    How does one execute a one time INSERT query inside the data window of a
    particular table for all records >1...

    The table has referential integrity on StateID...here is my stab but I am
    picking up a SYNTAX ERROR near 'Begin':


    IF (SELECT StateID
    FROM State
    WHERE StateID > 0) BEGIN
    (INSERT
    INTO State(StateBln)
    VALUES (1)
    WHERE StateID > 0) END

    The query needs to deposit the Int value (1) into newly created column
    StateBln...

    Thanks
    Jason


    Guest

  2. Similar Questions and Discussions

    1. INSERT file to column
      I have done some due diligence looking for an answer, but I have not found it so here is my post: I have a table t_CustomerFiles, with two...
    2. Return value of 'serial' column on insert
      Hi all, I have several tables with an 'id' column which is a simple 'serial unique' type. Often when I insert a record the next thing I need is...
    3. Index on Computed Column and ADO Insert
      Thanks nntp! <nntp> wrote in message news:#x9nW5OQDHA.1560@TK2MSFTNGP12.phx.gbl... was INSERT ON ARITHABORT with
    4. Have server get value for column on Insert?
      Consider: CREATE TABLE Transactions ( TransactionGUID uniqueidentifier, TransactionNumber int, TransactionDate, SessionGUID, ...) CREATE...
    5. Which is the best column to insert index...
      ...in a "linking" table? T1 ---------- Id--Name 1 -- xav 2 -- fab T2 ----------
  3. #2

    Default Re: Insert Bln into new column?

    com wrote: 
    You can't use WHERE with VALUES. What are you trying to do? Insert a new
    record? If so, you don't need a WHERE clause do you? Or are you trying to
    update an existing record? If so, you need to use an UPDATE statement, not
    an INSERT.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Guest

  4. #3

    Default Re: Insert Bln into new column?

    Damn, I'm stupid....too little sleep is my excuse! This works:

    UPDATE State
    SET StateBln = '1'
    WHERE (StateID > 0)

    Many thanks Bob
    Jason
    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:phx.gbl... 
    > You can't use WHERE with VALUES. What are you trying to do? Insert a new
    > record? If so, you don't need a WHERE clause do you? Or are you trying to
    > update an existing record? If so, you need to use an UPDATE statement, not
    > an INSERT.
    >
    > Bob Barrows
    > --
    > Microsoft MVP - ASP/ASP.NET
    > Please reply to the newsgroup. This email account is my spam trap so I
    > don't check it very often. If you must reply off-line, then remove the
    > "NO SPAM"
    >
    >[/ref]


    Guest

  5. #4

    Default Re: Insert Bln into new column?

    On Fri, 13 Aug 2004 12:11:02 -0400, <com> wrote:
     


    You could do the following as well if a row doesn't exist in a table
    then add a new row or update an existing one.


    IF EXISTS(SELECT StateID FROM State WHERE StateID > 0)
    BEGIN
    UPDATE State SET StateBln='1' WHERE StateID>0
    -- Some Error checking code here
    END
    ELSE
    BEGIN
    INSERT INTO State(StateBln) VALUES('1')
    -- Some Error checking code here
    END


    Also please don't top post on usenet.


    HTH

    Al

     
    >> You can't use WHERE with VALUES. What are you trying to do? Insert a new
    >> record? If so, you don't need a WHERE clause do you? Or are you trying to
    >> update an existing record? If so, you need to use an UPDATE statement, not
    >> an INSERT.
    >>
    >> Bob Barrows
    >> --
    >> Microsoft MVP - ASP/ASP.NET
    >> Please reply to the newsgroup. This email account is my spam trap so I
    >> don't check it very often. If you must reply off-line, then remove the
    >> "NO SPAM"
    >>
    >>[/ref]
    >[/ref]

    Harag Guest

  6. #5

    Default Re: Insert Bln into new column?

    Awesome!!! many thanks.

    ps: 'Top post' ? Not sure what this means....?

    -Jason
    "Harag" <net> wrote in message
    news:com... 
    >
    >
    > You could do the following as well if a row doesn't exist in a table
    > then add a new row or update an existing one.
    >
    >
    > IF EXISTS(SELECT StateID FROM State WHERE StateID > 0)
    > BEGIN
    > UPDATE State SET StateBln='1' WHERE StateID>0
    > -- Some Error checking code here
    > END
    > ELSE
    > BEGIN
    > INSERT INTO State(StateBln) VALUES('1')
    > -- Some Error checking code here
    > END
    >
    >
    > Also please don't top post on usenet.
    >
    >
    > HTH
    >
    > Al
    >
    > [/ref][/ref]
    column [/ref][/ref]
    new [/ref][/ref]
    to [/ref][/ref]
    not 
    > >[/ref]
    >[/ref]


    Guest

  7. #6

    Default Re: Insert Bln into new column?

    On Fri, 13 Aug 2004 14:08:54 -0400, <com> wrote:
     


    No probs. :)

     


    Top Post is exactly this posting at the very top of all the replies
    rather than posting below what your actually replying to.

    Personally I don't mind it (saves me scrolling down) as I read this
    using a offline browser and but a lot of people mind. so I've now
    started not to top post as well.

    HTH

    Al.

     
    >>
    >>
    >> You could do the following as well if a row doesn't exist in a table
    >> then add a new row or update an existing one.
    >>
    >>
    >> IF EXISTS(SELECT StateID FROM State WHERE StateID > 0)
    >> BEGIN
    >> UPDATE State SET StateBln='1' WHERE StateID>0
    >> -- Some Error checking code here
    >> END
    >> ELSE
    >> BEGIN
    >> INSERT INTO State(StateBln) VALUES('1')
    >> -- Some Error checking code here
    >> END
    >>
    >>
    >> Also please don't top post on usenet.
    >>
    >>
    >> HTH
    >>
    >> Al
    >>
    >> [/ref]
    >column [/ref]
    >new [/ref]
    >to [/ref]
    >not 
    >>[/ref]
    >[/ref]

    Harag Guest

  8. #7

    Default Re: Insert Bln into new column?

    On Fri, 13 Aug 2004 14:08:54 -0400, <com> wrote:
     

    just found this url that might exaplain it better than I did:

    http://www.caliburn.nl/topposting.html

    HTH

    Al

     
    >>
    >>
    >> You could do the following as well if a row doesn't exist in a table
    >> then add a new row or update an existing one.
    >>
    >>
    >> IF EXISTS(SELECT StateID FROM State WHERE StateID > 0)
    >> BEGIN
    >> UPDATE State SET StateBln='1' WHERE StateID>0
    >> -- Some Error checking code here
    >> END
    >> ELSE
    >> BEGIN
    >> INSERT INTO State(StateBln) VALUES('1')
    >> -- Some Error checking code here
    >> END
    >>
    >>
    >> Also please don't top post on usenet.
    >>
    >>
    >> HTH
    >>
    >> Al
    >>
    >> [/ref]
    >column [/ref]
    >new [/ref]
    >to [/ref]
    >not 
    >>[/ref]
    >[/ref]

    Harag Guest

  9. #8

    Default Re: Insert Bln into new column?

    Got it thanks!


    Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139