July 1, 2003 at 1:52 pm
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.
July 1, 2003 at 3:39 pm
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-
July 1, 2003 at 3:46 pm
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]
July 1, 2003 at 4:02 pm
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-
July 1, 2003 at 4:07 pm
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.
July 1, 2003 at 4:56 pm
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-
July 2, 2003 at 7:27 am
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]
July 2, 2003 at 7:33 am
Can you set field size within this table create ?
Thanks for your help. Rocko
July 2, 2003 at 9:23 am
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-
July 2, 2003 at 9:33 am
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