Is it a good idea to use COLUMN AS (left([Another_Column],(4)) instead of LEFT in the select?Which problems arise, declaring the size of all varchar parameters as max in stored proc?How to add/update a column with an incremented value and reset said value based on another column in SQLCan I create a computed column that requires input to select?Can I tell SQL Server not to place data in the buffer cache?Storing NULL versus storing '' in a varchar columnSQL Server - Sudden log autogrowth after database backupProper table design for sparse primary keyReclaim space from dropped column in SQLServer2008R2Int for identity/primary key and Guid for public identifier, best practices?

Delete n lines skip 1 line script

Incomplete iffalse: How to shift a scope in polar coordinate?

How do I automatically add linebreaks "\" to the end of each row of a tabular environment?

IEEE 754 square root with Newton-Raphson

How do we know neutrons have no charge?

Detail vs. filler

How to work around players whose backstory goes against the story?

What could cause lower torque than normal during cruise in a King Air 300?

Isn't the detector always measuring, and thus always collapsing the state?

Would a 737 pilot use flaps in nose dive?

Why does JSON parsing not fail on the first character for strings starting with "t"?

Is it good to engage in exceptional cases where it is permissible to do a typically forbidden action to which one has a taivah for

How to study endgames?

How is the Apple Watch ECG disabled in certain countries?

If a spaceship ran out of fuel somewhere in space between Earth and Mars, does it slowly drift off to the Sun?

What does it mean by "my days-of-the-week underwear only go to Thursday" in this context?

Are devices supposed to automatically be removed from iCloud when all content and settings are erased?

Is there an in-universe explanation of how Frodo's arrival in Valinor was recorded in the Red Book?

Is it possible to take a database offline when doing a backup using an SQL job?

Calculate the Ultraradical

Why does `FindFit` fail so badly in this simple case?

Should I be an author on another PhD student's paper if I went to their meetings and gave advice?

Is it possible for a company to grow but its stock price stays the same or decrease?

How to add the real hostname in the beginning of Linux cli command



Is it a good idea to use COLUMN AS (left([Another_Column],(4)) instead of LEFT in the select?


Which problems arise, declaring the size of all varchar parameters as max in stored proc?How to add/update a column with an incremented value and reset said value based on another column in SQLCan I create a computed column that requires input to select?Can I tell SQL Server not to place data in the buffer cache?Storing NULL versus storing '' in a varchar columnSQL Server - Sudden log autogrowth after database backupProper table design for sparse primary keyReclaim space from dropped column in SQLServer2008R2Int for identity/primary key and Guid for public identifier, best practices?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I came across a table like this:



CREATE TABLE TABLE1
(
CD1 int
,CD2 varchar(16)
,CD3 varchar(21)
,CD4 decimal(14,0)
,CD5 varchar(4)
,CD6 decimal(18,2)
,CD7 AS (left([CD3],(4)))
)


This table has more than 4 BILLION rows (totally unnecessary, but this is another topic).



As you can see in the last column, they use AS (left([CD3],(4))). I think this is pretty useless, since we almost NEVER have a SELECT on this table, and here is just using space.



Isn't it better to select that field during the select when needed?










share|improve this question
































    2















    I came across a table like this:



    CREATE TABLE TABLE1
    (
    CD1 int
    ,CD2 varchar(16)
    ,CD3 varchar(21)
    ,CD4 decimal(14,0)
    ,CD5 varchar(4)
    ,CD6 decimal(18,2)
    ,CD7 AS (left([CD3],(4)))
    )


    This table has more than 4 BILLION rows (totally unnecessary, but this is another topic).



    As you can see in the last column, they use AS (left([CD3],(4))). I think this is pretty useless, since we almost NEVER have a SELECT on this table, and here is just using space.



    Isn't it better to select that field during the select when needed?










    share|improve this question




























      2












      2








      2








      I came across a table like this:



      CREATE TABLE TABLE1
      (
      CD1 int
      ,CD2 varchar(16)
      ,CD3 varchar(21)
      ,CD4 decimal(14,0)
      ,CD5 varchar(4)
      ,CD6 decimal(18,2)
      ,CD7 AS (left([CD3],(4)))
      )


      This table has more than 4 BILLION rows (totally unnecessary, but this is another topic).



      As you can see in the last column, they use AS (left([CD3],(4))). I think this is pretty useless, since we almost NEVER have a SELECT on this table, and here is just using space.



      Isn't it better to select that field during the select when needed?










      share|improve this question
















      I came across a table like this:



      CREATE TABLE TABLE1
      (
      CD1 int
      ,CD2 varchar(16)
      ,CD3 varchar(21)
      ,CD4 decimal(14,0)
      ,CD5 varchar(4)
      ,CD6 decimal(18,2)
      ,CD7 AS (left([CD3],(4)))
      )


      This table has more than 4 BILLION rows (totally unnecessary, but this is another topic).



      As you can see in the last column, they use AS (left([CD3],(4))). I think this is pretty useless, since we almost NEVER have a SELECT on this table, and here is just using space.



      Isn't it better to select that field during the select when needed?







      sql-server sql-server-2008-r2 t-sql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 19:41









      Josh Darnell

      13.6k4 gold badges31 silver badges63 bronze badges




      13.6k4 gold badges31 silver badges63 bronze badges










      asked Mar 28 at 12:48









      Racer SQLRacer SQL

      3,5015 gold badges31 silver badges74 bronze badges




      3,5015 gold badges31 silver badges74 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          8
















          If the computed column isn't persisted or indexed, it's only a virtual column (expression), and it's not taking up any "space".






          share|improve this answer
































            4
















            The only reason I can think of for having that column is to index it, because there is some common set of read queries that filter on the first few characters in CD3.



            If the computed column is, indeed, indexed, then the it's valuable because:



            • it would required less storage than the full 21 char column

            • it would incur less page reads for seeks and scans than an index on the full 21 char column

            You mentioned the table is rarely read, but I would check for indexes that use this computed column to be sure.



            If it's not indexed, then see Erik's answer about the storage aspect of non-persisted computed columns.






            share|improve this answer



























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "182"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );














              draft saved

              draft discarded
















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f233382%2fis-it-a-good-idea-to-use-column-as-leftanother-column-4-instead-of-left-i%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              8
















              If the computed column isn't persisted or indexed, it's only a virtual column (expression), and it's not taking up any "space".






              share|improve this answer





























                8
















                If the computed column isn't persisted or indexed, it's only a virtual column (expression), and it's not taking up any "space".






                share|improve this answer



























                  8














                  8










                  8









                  If the computed column isn't persisted or indexed, it's only a virtual column (expression), and it's not taking up any "space".






                  share|improve this answer













                  If the computed column isn't persisted or indexed, it's only a virtual column (expression), and it's not taking up any "space".







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 12:49









                  Erik DarlingErik Darling

                  27.6k13 gold badges84 silver badges139 bronze badges




                  27.6k13 gold badges84 silver badges139 bronze badges


























                      4
















                      The only reason I can think of for having that column is to index it, because there is some common set of read queries that filter on the first few characters in CD3.



                      If the computed column is, indeed, indexed, then the it's valuable because:



                      • it would required less storage than the full 21 char column

                      • it would incur less page reads for seeks and scans than an index on the full 21 char column

                      You mentioned the table is rarely read, but I would check for indexes that use this computed column to be sure.



                      If it's not indexed, then see Erik's answer about the storage aspect of non-persisted computed columns.






                      share|improve this answer





























                        4
















                        The only reason I can think of for having that column is to index it, because there is some common set of read queries that filter on the first few characters in CD3.



                        If the computed column is, indeed, indexed, then the it's valuable because:



                        • it would required less storage than the full 21 char column

                        • it would incur less page reads for seeks and scans than an index on the full 21 char column

                        You mentioned the table is rarely read, but I would check for indexes that use this computed column to be sure.



                        If it's not indexed, then see Erik's answer about the storage aspect of non-persisted computed columns.






                        share|improve this answer



























                          4














                          4










                          4









                          The only reason I can think of for having that column is to index it, because there is some common set of read queries that filter on the first few characters in CD3.



                          If the computed column is, indeed, indexed, then the it's valuable because:



                          • it would required less storage than the full 21 char column

                          • it would incur less page reads for seeks and scans than an index on the full 21 char column

                          You mentioned the table is rarely read, but I would check for indexes that use this computed column to be sure.



                          If it's not indexed, then see Erik's answer about the storage aspect of non-persisted computed columns.






                          share|improve this answer













                          The only reason I can think of for having that column is to index it, because there is some common set of read queries that filter on the first few characters in CD3.



                          If the computed column is, indeed, indexed, then the it's valuable because:



                          • it would required less storage than the full 21 char column

                          • it would incur less page reads for seeks and scans than an index on the full 21 char column

                          You mentioned the table is rarely read, but I would check for indexes that use this computed column to be sure.



                          If it's not indexed, then see Erik's answer about the storage aspect of non-persisted computed columns.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 28 at 19:40









                          Josh DarnellJosh Darnell

                          13.6k4 gold badges31 silver badges63 bronze badges




                          13.6k4 gold badges31 silver badges63 bronze badges































                              draft saved

                              draft discarded















































                              Thanks for contributing an answer to Database Administrators Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f233382%2fis-it-a-good-idea-to-use-column-as-leftanother-column-4-instead-of-left-i%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                              Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                              Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript