Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Static Records in SELECT

Status
Not open for further replies.

RichardParry

IS-IT--Management
Aug 28, 2002
91
GB
Hi,

I was wondering how I can get data from a standard DB Table in the SELECT as per normal, but also set a column to static data, defined in the SELECT? I can do this in Access 2000 with SELECT MadeUpFieldColumn: "Repeat Data Here", Table.NormalField FROM Table

This works great in Access, but SQL 2000 won't allow it. Is there any way to do this in SQL (I am using a View)?


Thanx! Richard
 
Sure. It would look something like this...

Code:
Select Column1, 
       Column2,
       [!]'My Hardcoded Data' as ColumnAlias[/!]
From   TableName

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Ah, Thank you George! I was trying it with quotes and not apostrophes :( Thanx!
 
I don't think there is a single occasion to use the quote symbol in a query. Anywhere. In fact... grab a screwdriver (or similar prying instrument) and remove that key from your keyboard. Your queries will thank you.

Of course, using quotes will sometimes work, but your better off doing it another way.

For example....

Code:
Select 1 As "Whatever Column Alias You Want"

This will work, but the preferred method is...

Code:
Select 1 As [Whatever Column Alias You Want]

Use the square brackets instead.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top