Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Simple SQl question
I am trying to create a SQL statement that returns values from fields
in the database but I also need to return values that are NOT in the
database but hard coded int he SQL statement. The values along with the
names of the fields will be hardcoded into the SQL statement. I'm not
sure if this can be done.

It will be something like this:

SELECT    vchrFirstName,
vchrLastName,
'hardcoded value' AS myField
FROM       tblCustomer

The above statement does NOT work. It throws an error, but that is what
I am trying to do. Bascially I want the query to return the values for
vchrFirstName and vchrLastName which are in the database, but I also
want the field called "myField" to be returned in the recordset with
the value of "hardcoded value" for every record returned. I hope this
made sense and can be done. THANKS!


Report this thread to moderator Post Follow-up to this message
Old Post
Erich93063
12-30-05 01:24 AM


Re: Simple SQl question
Erich93063  wrote:
> I am trying to create a SQL statement that returns values from fields
> in the database but I also need to return values that are NOT in the
> database but hard coded int he SQL statement. The values along with the
> names of the fields will be hardcoded into the SQL statement. I'm not
> sure if this can be done.
>
> It will be something like this:
>
> SELECT    vchrFirstName,
>                  vchrLastName,
>                  'hardcoded value' AS myField
> FROM       tblCustomer
>
> The above statement does NOT work. It throws an error, but that is what
> I am trying to do. Bascially I want the query to return the values for
> vchrFirstName and vchrLastName which are in the database, but I also
> want the field called "myField" to be returned in the recordset with
> the value of "hardcoded value" for every record returned. I hope this
> made sense and can be done. THANKS!
>

Yes, it can be done, and your query should work.  What's the error
you're getting?

Report this thread to moderator Post Follow-up to this message
Old Post
Rob
12-30-05 01:24 AM


Re: Simple SQl question
OK, I must have been doing somethign else wrong, because now it's
working. It's working the way I did it in my post. Not sure what I did
wring before. hmmm THANKS


Report this thread to moderator Post Follow-up to this message
Old Post
Erich93063
12-30-05 01:24 AM


Re: Simple SQl question
Hi

At a guess you have SET QUOTED_IDENTIFIER ON and you are using double
quotes?

John

"Erich93063" <erich93063@gmail.com> wrote in message
news:1135891703.009269.19170@g43g2000cwa.googlegroups.com...
> OK, I must have been doing somethign else wrong, because now it's
> working. It's working the way I did it in my post. Not sure what I did
> wring before. hmmm THANKS
>



Report this thread to moderator Post Follow-up to this message
Old Post
John Bell
12-30-05 01:24 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

Microsoft SQL Server forum archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 04:05 AM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006