Solved

How do I reference a column name with an embedded space?

Posted on 2008-10-13
2
151 Views
Last Modified: 2012-08-14
I am trying to get just a few columns from a SQL Server table using:
SELECT col1, col2, col3 FROM tablename
However col3 is actually "Badge #"  (don't blame me - I didn't do the DDL!)

How do I specify the column name to transact SQL when it has an em bedded space?

Thanks!
Ken
0
Comment
Question by:kenfhenderson
2 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 500 total points
Comment Utility
wrap it in brackets.

select col1, col2, [badge #]
from [dbo].[Your Table can have spaces too]
0
 

Author Closing Comment

by:kenfhenderson
Comment Utility
Thanks super much for the quick answer!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now