Professional Web Applications Themes

syntax to dynamically create field names in an Update Query - Microsoft SQL / MS SQL Server

Nikhil Patel (com) writes:  In this case because ; as a statement terminator is ANSI SQL, and thus doented in the ANSI standards. Why semicolon is not doented in Books Online, I don't know, but I tend to assume that this is an oversight. -- Erland Sommarskog, SQL Server MVP, se Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp...

  1. #1

    Default Re: syntax to dynamically create field names in an Update Query

    Nikhil Patel (com) writes: 

    In this case because ; as a statement terminator is ANSI SQL, and thus
    doented in the ANSI standards. Why semicolon is not doented in
    Books Online, I don't know, but I tend to assume that this is an
    oversight.


    --
    Erland Sommarskog, SQL Server MVP, se

    Books Online for SQL Server SP3 at
    http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
    Erland Guest

  2. #2

    Default Re: syntax to dynamically create field names in an Update Query

    >>>
    Tony, you are making a fool of yourself. That is not embedded SQL,
    that is dynamic SQL in client code. That is not what Joe is talking
    about.

    Embedded SQL is when you in the middle of a C or a COBOL program has
    something like:

    BEGIN SQL
    SELECT :hostvar1 = col, :hostvar2 = col FROM tbl
    END SQL
    <<<<

    That is the point i'm trying to make and if you'd bothered to read my whole
    message you might have realised instead of resulting to an insult.

    MS SQL Server doesn't have a pre-processor, old legacy stuff like PL/1 and
    COBOL on the mainframe against DB2 does but thats no longer a mainstream
    langauge.

    When you develop now, if you embed SQL in the application you build a string
    dynamically in the application and execute it against the database.

    --
    Tony Rogerson
    SQL Server MVP
    http://www.sqlserverfaq.com?mbr=21
    (Create your own groups, Forum, FAQ's and a ton more)


    Tony Guest

  3. #3

    Default Re: syntax to dynamically create field names in an Update Query

    I used to code on the IBM mainframe for about 5 years using PL/1, CICS and
    DBS, we embedded SQL in the way you mention, the execution plan was bound
    in the application executable and did not change even if volumes changed
    etc...

    MS SQL Server does not allow for bound execution plans.

    Looking at books online it looks as though the embedded SQL compiler for SQL
    Server creates a stored procedure for the embedded SQL anyway!

    --
    Tony Rogerson
    SQL Server MVP
    http://www.sqlserverfaq.com?mbr=21
    (Create your own groups, Forum, FAQ's and a ton more)


    Tony Guest

  4. #4

    Default Re: syntax to dynamically create field names in an Update Query

    relax,

    let me say it this way: in versions past yukon using semicolons to separate
    SQL statements will be *required*. or if you like: not using semicolons will
    be deprecated.

    so if still skipping it start putting it there if you want to be up to date!
    :-))

    cheers,
    </wqw>

    "raydan" <nospamcom> wrote in message
    news:#phx.gbl... 
    queryName2;exec 
    > >
    > > While not doented anywhere in Books Online as I can recall, you can
    > > indeed use ; as a statement terminator in T-SQL since SQL7.
    > >
    > > --
    > > Erland Sommarskog, SQL Server MVP, se
    > >
    > > Books Online for SQL Server SP3 at
    > > http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp[/ref]
    >
    >[/ref]


    Vlad Guest

Similar Threads

  1. Syntax error when trying to update date/time field
    By hazalj in forum Coldfusion Database Access
    Replies: 3
    Last Post: January 31st, 10:17 PM
  2. Need help formatting syntax for SELECT query on a Bittype data field
    By ca_nimrod in forum Coldfusion Database Access
    Replies: 2
    Last Post: January 11th, 03:23 AM
  3. Replies: 6
    Last Post: September 12th, 01:17 PM
  4. Syntax error in UPDATE query
    By trey2233 in forum Coldfusion Database Access
    Replies: 9
    Last Post: July 1st, 01:20 PM
  5. Dynamically loading names in batches
    By rabblerouser in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: March 11th, 04:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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