How to do this with SQL

  • Thread starter Thread starter Mika M
  • Start date Start date
M

Mika M

Hi!

This is not clearly ADO.NET question, but I need this with VB.NET and
ADO.NET anyway.

It is possible to make SQL-query like ...

SELECT 0 AS IntegerField, '' AS StringField ...

.... to get field which really don't exists in database, but how to get this
kind of "virtual field" as boolean type (true or false)?

I need this as an aid field for user's temporary marking use with real
database fields when form is loaded in SELECT SQL-query with ADO.NET.
 
You can write queries like that, although you still have to end the query.
For example, you final query is something like:

SELECT col1, col2 FROM Table1

You can do the following:

SELECT TOP 10 0 AS col1, '' AS col2
FROM Table1

You can also create DataTables on the fly, if it is more applicable to your
needs.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
Not sure why you need to do this, but try this:

select 0 as IntFieldName, cast(null as bit) as BitFieldName from TableName
 
Hi,

The answer is yes, but it depends on the dbms how.

For instance if you're using msaccess
SELECT 0 AS IntegerField, '' AS StringField, true AS BooleanField;

But if you're using SQL-Server
SELECT 0 AS IntegerField, '' AS StringField, Convert(BIT,-1) AS
BooleanField;

You should be able to test queries and there output in the enviroment of the
dbms your using.
msaccess:
- Create queries, run it, view the sql and delete the dummy-query
afterwards.
SqlServer:
- Use the Queryanalyzer tool to play with the T-SQL.

Anywhy, whatever tool you use (mabye TOAD is you're thing), you should play
with the SQL to get to know it's habbits.

Good luck.
 
Back
Top