Field Size

  • How do you set the size of a field in a query?

    The field I am creating is a substr that sets

    the output - maybe default - to 8000 char.

  • I hope this is what you are asking

    SELECT CONVERT( VARCHAR( 40 ), MyColumn ) AS MyColumn

    If not - please explain a little more about your situation.

    Guarddata-

  • I have this logic that I create the field called [WILD CARD]. The table that I create with the Query has an output of 8000 varchar.

    Can I add the output size of 8 char to this statement ? Where would I put in statement?

    SELECT Distinct

    TOP 100 PERCENT [Vin 8], REPLACE(LEFT([Vin 8], 8), ' ', '_') AS [Wild Card]

  • The example shows two columns being returned [Vin 8] and the first 8 characters of [Vin 8]. REPLACE(LEFT([Vin 8], 8), ' ', '_') AS [Wild Card] only outputs those 8 characters. What is it that you are seeing that you need to change?

    Guarddata-

  • The [WILD CARD] field in the table that is created shows a filed size of 8000 varchar

    I do not know wht it does this - I wanted to know if I could set the field size again.

  • Sorry ROCKO, I must be misunderstanding something because all my tests yield 8 - not 8000. When you say the table that is created - what do you mean? Are you creating a table using SELECT INTO? Please post the code in context.

    Guarddata-

  • Here is the code. When I look at the table that is created it has varchar set to 8000.

    SELECT Distinct

    TOP 100 PERCENT

    [Vin 8], REPLACE(LEFT([Vin 8], 8), ' ', '_') AS [Wild Card],

    [Vin 10], [Model Year], Make, Model, Style, [Model Number],

    REPLACE(LEFT([Model Number], 10), '*', '_') AS [Wild Card2],

    into temp1

    FROM dbo.MayJune2003

    WHERE ([Vin 8] <> ' ') AND ([Vin 10] <> ' ') AND ([Style Code] <> ' ')

    ORDER BY [Vin 8], [Vin 10], [Style Code]

  • Can you set field size within this table create ?

    Thanks for your help. Rocko

  • ROCKO - sorry for being slow on this. Thanks for the code - it really cleared this up for me. Try this...

    [Vin 8], CONVERT( VARCHAR(8), REPLACE(LEFT([Vin 8], 8), ' ', '_')) AS [Wild Card],

    [Vin 10], [Model Year], Make, Model, Style, [Model Number], CONVERT( VARCHAR(10), REPLACE(LEFT([Model Number], 10), '*', '_')) AS [Wild Card2],

    Hope this works for you.

    Guarddata-

  • Thanks Guarddata - that work Great !

    I appreicate the current and past post .

    Rocko

Viewing 10 posts - 1 through 9 (of 9 total)

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