Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:29:07+00:00 2026-06-11T18:29:07+00:00

I have three fields that I concatenated into one field, but when I run

  • 0

I have three fields that I concatenated into one field, but when I run the query the result-set is correct, but they are not evenly spaced within the one field. How would I space them neatly and correctly. Thank-you for the help.

Here is the query:

SELECT CONVERT(varchar(20),Book)+ Space(2) + '(' + CONVERT(varchar(30),Year)
+ ')' + Space(2) + '(' + CONVERT(varchar(30),Print) + ')' As  'Film Description', Genre,
Cost
FROM Film
Order By Year DESC, Book ASC
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:29:08+00:00Added an answer on June 11, 2026 at 6:29 pm

    Since VARCHAR ignores trailing spaces, you need to use a different data type that doesn’t (e.g. CHAR). A few other comments:

    • be careful about using reserved words such as year and print as column names
    • be careful about using 'single quotes' as alias delimiters ([square brackets] are more future-proof and harder to muddle with string literals)
    • you should use the schema prefix (e.g. dbo.Film)
    DECLARE @Film TABLE(Book VARCHAR(255), [Year] INT, [Print] VARCHAR(255));
    
    INSERT @Film 
    SELECT 'a', 2012, 'hello there this is at least 30 characters, right?'
    UNION ALL 
    SELECT 'this must be at least 30 characters too, right?', 2011, 'b';
    
    SELECT CONVERT(CHAR(20), Book)
     + SPACE(2) 
     + '(' + CONVERT(CHAR(4),[Year]) + ')' 
     + SPACE(2) 
     + '(' + CONVERT(CHAR(30), [Print]) + ')' 
     As [Film Description]
    FROM @Film
    Order By [Year] DESC, Book;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three fields that must be unique in a table, and based on
I have a list, that has three fields: Title, PublishingRollupImage and Description. I want
I have a program that uses three JTextField fields as the main data entry
I have a query that's selecting a bunch of fields related to names and
I have written an application that allows a user to define a query, run
So I have a class with three fields that maps to a table using
I have a webpage that has 3 file inputs. There are specific fields on
I have a view that shows user profile fields in a tabular format. There
I have an Item class. There's an itemType field inside of that class which
I have a combobox that is filled with data field JobCode from database. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.