Dynamic SQL To Update Table With CASE

  • Thanks, Jeff! I appreciate the kind words and the welcome aboard.

    Jeffrey Williams-493691 (4/30/2010)


    I have to agree with the others, good start on posting. I did want to point out one thing that I have found helps me out with dynamic SQL and quotes. There is a nice utility that will do the quoting for you.

    SELECT quotename('SomeValue') -- defaults to []

    SELECT quotename('SomeValue', char(39)) -- single-quotes

    SELECT quotename('SomeValue', char(34)) -- double-quotes

    Thank you, Jeffrey! This will most definitely be put to use in many places across our applications where I currently use other methods for appending quotes/brackets/double quotes onto string values. Thanks for pointing this out! ...so simple yet it yields very helpful results...

    Rajesh, thanks for your input as well.

    rajesh.subramanian (5/4/2010)


    2. In future if the development project is going for any sort of enhancement please try to implement partition in the database for the historical tables.. You can have all the 180 milloin + values in the same table logically and you can split and store them physically in different files.. And when the developers querying they need to add the partition key values in the WHERE clause to fetch the results faster.

    While I appreciate your feedback, I don't have any plans to update the entire infrastructure of this database as our current SOW for this application would not cover the amount of rework needed on both the database and front-end application sides. Thanks though!

    Comments, whether good or bad towards my current methods of execution in this particular database, are all helping bring to light newer methods of achieving the same type of results, but through someone elses eyes - whereas my eyes are focused on what I know and what works best for me. So even though I have no use for it now, it's great knowledge to have for future reference, so thanks again.

    Danny Sheridan
    Comtekh, Inc.

  • Danny Sheridan (5/4/2010)


    Thanks, Jeff! I appreciate the kind words and the welcome aboard.

    Jeffrey Williams-493691 (4/30/2010)


    I have to agree with the others, good start on posting. I did want to point out one thing that I have found helps me out with dynamic SQL and quotes. There is a nice utility that will do the quoting for you.

    SELECT quotename('SomeValue') -- defaults to []

    SELECT quotename('SomeValue', char(39)) -- single-quotes

    SELECT quotename('SomeValue', char(34)) -- double-quotes

    Thank you, Jeffrey! This will most definitely be put to use in many places across our applications where I currently use other methods for appending quotes/brackets/double quotes onto string values. Thanks for pointing this out! ...so simple yet it yields very helpful results...

    Agreed. I knew about quotename, but wasn't aware you could supply the second parameter to it. I really need to just sit down and go through BOL one day so I cover the oddball functions that you rarely see but are really helpful when you do need them. (Things like SIGN(), PARSENAME(), etc.) It's been on my to do list forever, it just keeps being pushed back.

    Danny Sheridan (5/4/2010)


    While I appreciate your feedback, I don't have any plans to update the entire infrastructure of this database as our current SOW for this application would not cover the amount of rework needed on both the database and front-end application sides. Thanks though!

    Comments, whether good or bad towards my current methods of execution in this particular database, are all helping bring to light newer methods of achieving the same type of results, but through someone elses eyes - whereas my eyes are focused on what I know and what works best for me. So even though I have no use for it now, it's great knowledge to have for future reference, so thanks again.

    We've all got limitations on the things we can do in our environments. There are tons of great ideas that simply can't be implemented at the current time. Trust me, I know all about it. That said, it's still extremely beneficial to know that the other methods exist so you can keep your eyes open for other places that they potentially could be implemented. It's always nice when people can see that and evaluate the ideas for their own merit / learn things from them even when they're not practical for the current situation.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply