Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.

  1. #1

    Default Partial Index

    Can someone tell if it's possible to partially index a
    varchar. For instance, I have a varchar(40) field, but I
    don't want to index all 40 characteres; I want to index
    the first 15 characters. Is this possible? And if it is,
    how might one write the SQL statement. I've tried using
    the Substring function, but it has failed to work.

    Thanks,

    Maggy
    Maggy Guest

  2. Similar Questions and Discussions

    1. partial index on boolean, problem with v8.0.0rc1
      Hi all, PostgreSQL v8.0.0rc1, two variants of a "user_msg" table: create table user_msg ( message_id integer not null references message(id)...
    2. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
      Hey Folks,(New to .NET) This is driving me NUTZ... If anyone out there can resolve this from me I would greatly appreciate it... Line 238: Line...
    3. Newb query: index.htm & index.php & the server default
      The problem I'm trying to solve is as follows: The website has two subdirectories: /ordinary and /phpstuff. Users typing hostname/ordinary get the...
    4. Partial Borders
      I'm printing using an Epson 640 with an XP driver downloaded from the Epson site from Photoshop Elements 2.0. If I select a border in Print...
    5. Put partial text
      Hi, Reading from the registry I get a string like "C:\Program Files\Abobe\Illustrator\illustrator.exe". set installtypeOverview=...
  3. #2

    Default Re: Partial Index


    I thinks it is possible, but you have to change some things. Look this
    example:

    CREATE TABLE [dbo].[example] (
    [a] [varchar] (40) COLLATE Traditional_Spanish_CI_AS NOT NULL ,
    [b] AS (left([a],15))
    ) ON [PRIMARY]
    GO

    set
    ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_YIELDS_NULL ,ARITHABORT,QUOTED_IDENTIF
    IER,ANSI_NULLS on
    GO

    set NUMERIC_ROUNDABORT off
    GO

    CREATE INDEX [IX_example] ON [dbo].[example]([b]) ON [PRIMARY]
    GO

    set arithabort OFF
    GO

    set numeric_roundabort OFF
    GO

    set quoted_identifier OFF
    GO



    --
    --

    Un saludo

    --
    --
    ----------------------------------------------
    "Sólo sé que no sé nada. " (Sócrates)

    (Guía de netiquette del foro)
    [url]http://www.helpdna.net/bosqlfaq00.htm[/url]
    [url]http://perso.wanadoo.es/rubenvigon/foro[/url]

    (FAQ's de SQL Server)
    [url]http://support.microsoft.com/default.aspx?scid=/support/sql/70faq.asp[/url]
    [url]http://www.helpdna.net/bosqlfaq.htm[/url]

    "Andrew J. Kelly" <sqlmvpnooospam@shadhawk.com> escribió en el mensaje
    news:enYUuaJQDHA.1584@TK2MSFTNGP11.phx.gbl...
    > It is not possible to do that at this time.
    >
    > --
    >
    > Andrew J. Kelly
    > SQL Server MVP
    >
    >
    > "Maggy" <rmagnus@solutran.com> wrote in message
    > news:407601c34096$23da5890$a401280a@phx.gbl...
    > > Can someone tell if it's possible to partially index a
    > > varchar. For instance, I have a varchar(40) field, but I
    > > don't want to index all 40 characteres; I want to index
    > > the first 15 characters. Is this possible? And if it is,
    > > how might one write the SQL statement. I've tried using
    > > the Substring function, but it has failed to work.
    > >
    > > Thanks,
    > >
    > > Maggy
    >
    >

    Carlos Sacristan Guest

  4. #3

    Default Re: Partial Index

    Well yes, if you want to create a new column then you can index it. But you
    can't use expressions in the index definition itself.

    --

    Andrew J. Kelly
    SQL Server MVP


    "Carlos Sacristan" <csacristanARROBAocasoPUNTOes> wrote in message
    news:ONOhrjJQDHA.2256@TK2MSFTNGP11.phx.gbl...
    >
    > I thinks it is possible, but you have to change some things. Look this
    > example:
    >
    > CREATE TABLE [dbo].[example] (
    > [a] [varchar] (40) COLLATE Traditional_Spanish_CI_AS NOT NULL ,
    > [b] AS (left([a],15))
    > ) ON [PRIMARY]
    > GO
    >
    > set
    >
    ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_YIELDS_NULL ,ARITHABORT,QUOTED_IDENTIF
    > IER,ANSI_NULLS on
    > GO
    >
    > set NUMERIC_ROUNDABORT off
    > GO
    >
    > CREATE INDEX [IX_example] ON [dbo].[example]([b]) ON [PRIMARY]
    > GO
    >
    > set arithabort OFF
    > GO
    >
    > set numeric_roundabort OFF
    > GO
    >
    > set quoted_identifier OFF
    > GO
    >
    >
    >
    > --
    > --
    >
    > Un saludo
    >
    > --
    > --
    > ----------------------------------------------
    > "Sólo sé que no sé nada. " (Sócrates)
    >
    > (Guía de netiquette del foro)
    > [url]http://www.helpdna.net/bosqlfaq00.htm[/url]
    > [url]http://perso.wanadoo.es/rubenvigon/foro[/url]
    >
    > (FAQ's de SQL Server)
    > [url]http://support.microsoft.com/default.aspx?scid=/support/sql/70faq.asp[/url]
    > [url]http://www.helpdna.net/bosqlfaq.htm[/url]
    >
    > "Andrew J. Kelly" <sqlmvpnooospam@shadhawk.com> escribió en el mensaje
    > news:enYUuaJQDHA.1584@TK2MSFTNGP11.phx.gbl...
    > > It is not possible to do that at this time.
    > >
    > > --
    > >
    > > Andrew J. Kelly
    > > SQL Server MVP
    > >
    > >
    > > "Maggy" <rmagnus@solutran.com> wrote in message
    > > news:407601c34096$23da5890$a401280a@phx.gbl...
    > > > Can someone tell if it's possible to partially index a
    > > > varchar. For instance, I have a varchar(40) field, but I
    > > > don't want to index all 40 characteres; I want to index
    > > > the first 15 characters. Is this possible? And if it is,
    > > > how might one write the SQL statement. I've tried using
    > > > the Substring function, but it has failed to work.
    > > >
    > > > Thanks,
    > > >
    > > > Maggy
    > >
    > >
    >
    >

    Andrew J. Kelly Guest

  5. #4

    Default Re: Partial Index


    That's because I said to Maggy 'you have to change some things' ;-)


    --
    --

    Un saludo

    --
    --
    ----------------------------------------------
    "Sólo sé que no sé nada. " (Sócrates)

    (Guía de netiquette del foro)
    [url]http://www.helpdna.net/bosqlfaq00.htm[/url]
    [url]http://perso.wanadoo.es/rubenvigon/foro[/url]

    (FAQ's de SQL Server)
    [url]http://support.microsoft.com/default.aspx?scid=/support/sql/70faq.asp[/url]
    [url]http://www.helpdna.net/bosqlfaq.htm[/url]

    "Andrew J. Kelly" <sqlmvpnooospam@shadhawk.com> escribió en el mensaje
    news:ug$v$wJQDHA.3192@TK2MSFTNGP10.phx.gbl...
    > Well yes, if you want to create a new column then you can index it. But
    you
    > can't use expressions in the index definition itself.
    >
    > --
    >
    > Andrew J. Kelly
    > SQL Server MVP
    >
    >
    > "Carlos Sacristan" <csacristanARROBAocasoPUNTOes> wrote in message
    > news:ONOhrjJQDHA.2256@TK2MSFTNGP11.phx.gbl...
    > >
    > > I thinks it is possible, but you have to change some things. Look
    this
    > > example:
    > >
    > > CREATE TABLE [dbo].[example] (
    > > [a] [varchar] (40) COLLATE Traditional_Spanish_CI_AS NOT NULL ,
    > > [b] AS (left([a],15))
    > > ) ON [PRIMARY]
    > > GO
    > >
    > > set
    > >
    >
    ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_YIELDS_NULL ,ARITHABORT,QUOTED_IDENTIF
    > > IER,ANSI_NULLS on
    > > GO
    > >
    > > set NUMERIC_ROUNDABORT off
    > > GO
    > >
    > > CREATE INDEX [IX_example] ON [dbo].[example]([b]) ON [PRIMARY]
    > > GO
    > >
    > > set arithabort OFF
    > > GO
    > >
    > > set numeric_roundabort OFF
    > > GO
    > >
    > > set quoted_identifier OFF
    > > GO
    > >
    > >
    > >
    > > --
    > > --
    > >
    > > Un saludo
    > >
    > > --
    > > --
    > > ----------------------------------------------
    > > "Sólo sé que no sé nada. " (Sócrates)
    > >
    > > (Guía de netiquette del foro)
    > > [url]http://www.helpdna.net/bosqlfaq00.htm[/url]
    > > [url]http://perso.wanadoo.es/rubenvigon/foro[/url]
    > >
    > > (FAQ's de SQL Server)
    > > [url]http://support.microsoft.com/default.aspx?scid=/support/sql/70faq.asp[/url]
    > > [url]http://www.helpdna.net/bosqlfaq.htm[/url]
    > >
    > > "Andrew J. Kelly" <sqlmvpnooospam@shadhawk.com> escribió en el mensaje
    > > news:enYUuaJQDHA.1584@TK2MSFTNGP11.phx.gbl...
    > > > It is not possible to do that at this time.
    > > >
    > > > --
    > > >
    > > > Andrew J. Kelly
    > > > SQL Server MVP
    > > >
    > > >
    > > > "Maggy" <rmagnus@solutran.com> wrote in message
    > > > news:407601c34096$23da5890$a401280a@phx.gbl...
    > > > > Can someone tell if it's possible to partially index a
    > > > > varchar. For instance, I have a varchar(40) field, but I
    > > > > don't want to index all 40 characteres; I want to index
    > > > > the first 15 characters. Is this possible? And if it is,
    > > > > how might one write the SQL statement. I've tried using
    > > > > the Substring function, but it has failed to work.
    > > > >
    > > > > Thanks,
    > > > >
    > > > > Maggy
    > > >
    > > >
    > >
    > >
    >
    >

    Carlos Sacristan 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