Click to See Complete Forum and Search --> : SQL Question - Returning a non-existant field


Dudsmack
04-25-2005, 12:23 PM
I have an SQL query and I would like it to return a field that does not exist with a preset value; kinda like:

SELECT * FROM table1, bob="this"

In that this would return all the fields, plus a new one bob with a value of "this"

A1ien51
04-25-2005, 12:29 PM
SELECT 'this' As bob, * FROM table1


Eric

Dudsmack
04-25-2005, 01:05 PM
Is there a way to set the type of value it returns? Say I string with a lenght of 7?

NogDog
04-25-2005, 03:55 PM
You could use rpad() (or lpad), perhaps?

SELECT RPAD('this', 7, ' ') AS bob, * FROM table1

CardboardHammer
04-25-2005, 04:06 PM
In the general sense, it depends on the DBMS you're using. CAST and CONVERT work for SQL Server 2000, with CAST being preferred.