Applies To:
  • MS SQL Server 2008 R2
  • MS Windows 7 Enterprise (Client)
  • MS Excel 2010

What?
A really quick note on how to insert a carriage return or new line into the column name/alias (the header). It might seem trivial but these little aesthetic changes done at the database level can save some time.

Why?
I have an Excel report which dynamically gets its content from a data source located on a database on the other side of the world. I want the header in the column "Academic Week" to break across two lines so that the column doesn't expand to the width of "Academic Week" and instead expands to the width of the word "Academic".

What I have:
copyraw
Academic Week    Monday      Tuesday     Wednesday   Thursday    Friday
---------------- ----------- ----------- ----------- ----------- -----------
1                14-Jul-2014 15-Jul-2014 16-Jul-2014 17-Jul-2014 18-Jul-2014
2                21-Jul-2014 22-Jul-2014 23-Jul-2014 24-Jul-2014 25-Jul-2014
...
  1.  Academic Week    Monday      Tuesday     Wednesday   Thursday    Friday 
  2.  ---------------- ----------- ----------- ----------- ----------- ----------- 
  3.  1                14-Jul-2014 15-Jul-2014 16-Jul-2014 17-Jul-2014 18-Jul-2014 
  4.  2                21-Jul-2014 22-Jul-2014 23-Jul-2014 24-Jul-2014 25-Jul-2014 
  5.  ... 
What I want:
copyraw
Academic 
Week      Monday      Tuesday     Wednesday   Thursday    Friday
--------- ----------- ----------- ----------- ----------- -----------
1         14-Jul-2014 15-Jul-2014 16-Jul-2014 17-Jul-2014 18-Jul-2014
2         21-Jul-2014 22-Jul-2014 23-Jul-2014 24-Jul-2014 25-Jul-2014
...
  1.  Academic 
  2.  Week      Monday      Tuesday     Wednesday   Thursday    Friday 
  3.  --------- ----------- ----------- ----------- ----------- ----------- 
  4.  1         14-Jul-2014 15-Jul-2014 16-Jul-2014 17-Jul-2014 18-Jul-2014 
  5.  2         21-Jul-2014 22-Jul-2014 23-Jul-2014 24-Jul-2014 25-Jul-2014 
  6.  ... 


How?
To do this in a select query resultset, you insert the special character references "CHAR(10)" [line feed] and "CHAR(13)" [carriage return] but to do this in the name of the column heading, the answer is a much simpler one,
Category: SQL Server :: Article: 568

Download Connectors from dev.MySQL.com

MySQL Connector/Net

Type: .NET Framework Class Library
Usage: MySql.Data.MySqlClient.MySqlConnection
Manufacturer: MySQL

Standard
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; 
Default port is 3306.

Specifying port
copyraw
Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
  1.  Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword; 

Category: SQL Server :: Article: 310

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

RSS Feed

Related Articles

Joes Revolver Map

Joes Word Cloud

used   uploaded   deluge   server   data   work   form   display   file   windows   license   code   script   would   page   find   where   following   user   time   files   zoho   parameter   table   using   version   error   list   date   added   source   need   order   name   function   google   value   client   case   field   first   system   joomla   create   report   creator   website   mysql   note   database   JoelLipman.Com

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.