How To Write A Comparison Expression

Dec 8, 2006

Hi,
i need a column in a SELECT statement which returns always "true" (As a boolean value, not as a string)

so I first tried

SELECT field1, field2, true AS field3

but this is not working. If I use "0 AS field3" this returns fine the 0, but this is not a boolean but a int.
I also tried to make something like

    "0 = 0 AS field"

but also errors. In that context I discoverd that I could not compare values in the select field - I can use +,-+,* ... for having something like "2 * field1 AS field3" but I'm not clever enough to figure out how I would have a field "field1 < 12 AS field3" (ok I would use CASE, but I need the boolean return value...)

Any ideas?
Thanks in advance,
Klaus



how could I write something

View 3 Replies


ADVERTISEMENT

Using Comparison Operators In Query Expression

Sep 14, 2006

I'm trying to put an expression into a view query column. I've already created a column which contains the results of a calculation in the form of an expression. What I don't know how to do is use comparison operators to return a boolean value for display. I'll give some examples of what I'm trying to do, using literal values just to simplify things...

So say I want to display the result of an expression in a view query column, as a boolean value (or BIT), as True or False. I've tried putting the following expressions into the column and none work:

4 < 5: Access converts this to the string '4 < 5' and it's just displayed as a string.

CAST( '4 < 5' AS BIT ): When run, the query displays the error 'Syntax error converting the varchar value '4 < 5' to a column of data type BIT.

Although I'm using Access 2003, It's just a front end for a SQL Server 2000 database. The actual SQL statement containing the latter SQL function is:

SELECT dbo.Tapes.No, dbo.Tapes.Status, dbo.Tapes.LastWrittenDate, dbo.Tapes.Pool, dbo.Tapes.Location, dbo.TapeJobs.No AS Expr1, dbo.TapeJobs.JobNo,
dbo.TapeJobs.TapeNo, dbo.Jobs.No AS Expr2, dbo.Jobs.Date, dbo.Jobs.Successful, dbo.Jobs.RetentionRule, dbo.RetentionRules.No AS Expr3,
dbo.RetentionRules.Name, dbo.RetentionRules.Description, dbo.RetentionRules.RetentionPeriod, dbo.RetentionRules.RetentionCycles,
dbo.Jobs.Date + dbo.RetentionRules.RetentionPeriod AS AgedJob, CAST('4 < 5' AS BIT) AS Expr4
FROM dbo.RetentionRules INNER JOIN
dbo.Jobs ON dbo.RetentionRules.No = dbo.Jobs.RetentionRule RIGHT OUTER JOIN
dbo.Tapes RIGHT OUTER JOIN
dbo.TapeJobs ON dbo.Tapes.No = dbo.TapeJobs.TapeNo ON dbo.Jobs.No = dbo.TapeJobs.JobNo

I'm new to SQL. I think the CAST function is the way forward, but I just don't know how to force it to resolve the expression '4 < 5'.

Can someone please help ?



--
Paul Anderson

View 8 Replies View Related

Like Comparison Operator In An Expression To Ignore Case

Aug 31, 2007

How do you make the "Like" comparison operator ignore case in an expression??

Expression looks like this:




Code SnippetParameters!CompanyFilterOp.Value = "%",Fields!company.Value like "*" & Parameters!Company.Value & "*"





BTW, the expression above is part of a switch expression, and is at the table level.

Data contains "General Industry" in Company column from database.

User enters "indust" in Company Parameter text box, and result is no data found.

User enters "Indust" in Company Parameter text box, and data is returned.

Thanks in advance for your time in responding.

View 3 Replies View Related

How To Write Expression For This...

Feb 22, 2007

=Fields!net_comissionable.Value-(Val(ReportItems!textbox14.value) * Val(ReportItems!staffed_hrs.Value))*14.43

this is in a text box that is calculating the referanced box's and I am looking for the expresion that would be if the result of this is <than 0 to return as a 0
if thenn statment or a case statment how does this work.

Thanks

View 1 Replies View Related

Write A Date Back To A Table In An Expression

Mar 12, 2008

Help,

I have a package that maps the current getdate to a variable.

I then want to be able to write that variable back to a table using a sql task using the following expression:

"INSERT INTO CONTROL_BATCH_HEADER VALUES (
" + (DT_STR, 10, 1252) @[Control::intAdtBatchId] + ",
'" + @[Control::strSubjectArea] + "',
convert(datetime, '" + (DT_STR, 30, 1252) @[Control::dteRunDate] + "',131))"


The problem is the date is being written back in the wrong format. I've tried changing the mask to 121 but the month is being written as the day.

Help, how can I make this work regardless of the locals. In oracle I would just put a to_char(date,'dd-mm-yyyy') but not sure what to do here.

Thanks for your help

Stapsey

View 1 Replies View Related

URGENT - My Error Or Bug? The Result Of The Expression Cannot Be Written To The Property. The Expression Was Evaluated, But

Feb 8, 2007

Error 3 Error loading MLS_AZ_PHX.dtsx: The result of the expression ""C:\sql_working_directory\MLS\AZ\Phoenix\Docs\Armls_Schema Updated 020107.xls"" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property. c:documents and settingsviewmastermy documentsvisual studio 2005projectsm l sMLS_AZ_PHX.dtsx 1 1


"C:\sql_working_directory\MLS\AZ\Phoenix\Docs\Armls_Schema Updated 020107.xls"

Directly using C:sql_working_directoryMLSAZPhoenixDocsArmls_Schema Updated 020107.xls
as connectionString works

However - I'm trying to deploy the package - and trying to use expression:
@[User::DIR_WORKING] + "\Docs\Armls_Schema Updated 020107.xls"
which causes the same error to occur

(Same error with other Excel source also:
Error 5 Error loading MLS_AZ_PHX.dtsx: The result of the expression "@[User::DIR_WORKING] + "\Docs\Armls_SchoolCodesJuly06.xls"" on property "ConnectionString" cannot be written to the property. The expression was evaluated, but cannot be set on the property. c:documents and settingsviewmastermy documentsvisual studio 2005projectsm l sMLS_AZ_PHX.dtsx 1 1
)

View 4 Replies View Related

Reporting Services :: Running Value Expression Within Lookup Expression In SSRS?

Oct 28, 2015

I have created 1 report with 2 datasets. This report is attached to the 1st dataset.For example,1st one is "Smallappliances", 2nd is "Largeappliances".

I created a tablix and, the 1st column extracts Total sales per Sales person between 2 dates from 1st dataset (Small appliances). I used running values expression and it works fine.

Now, I would like to add another column that extracts Total sales per sales person between 2 dates from 2nd dataset (Large appliances). I am aware that I need to use Lookup expression and it is giving me the single sales value rather than the total sales values. So, I wanted to use RunningValue expression within lookup table to get total sales for large appliances.

This is the lookup expression that I added for the 2nd column.

=Lookup(Fields!salesperson.Value,Fields!sales_person.Value,RunningValue(Fields!sales_amount.Value,
sum, " sales_person"),
"Largeappliances").

I get this error when I preview the report.An error occurred during local report processing.The definition of the report is invalid.An unexpected error occurred in report processing.

(processing): (SortExpression ++ m_context.ExpressionType)

View 7 Replies View Related

Backup Master Key, Cannot Write Into File 'c: Empmaster'. Verify That You Have Write Permissions, That The File Path Is Valid.

Jul 12, 2006

Hi,



I tried to backup the master key by the following syntax :

OPEN MASTER KEY DECRYPTION BY PASSWORD = 'mypassword'

BACKUP MASTER KEY TO FILE = 'c: empmaster' ENCRYPTION BY PASSWORD = 'mypassword'

but it failed and i got the following message:

Cannot write into file 'c: empmaster'. Verify that you have write permissions, that the file path is valid, and that the file does not already exist.

NB: I am using the "sa" user to execute this command.

I know that we have a security permission issue , but where and how ?



Regards,

Tarek Ghazali

SQL Server MVP

View 12 Replies View Related

Comparison

Nov 23, 2000

Dear All

I am new to the topic T-SQL.
I am trying to use T-SQL to merge the content of two tables (table1 and table2) into one table making sure there are no duplication.

I wonder if any body can let me have a simple code.

Best Regards
Saad

View 1 Replies View Related

Comparison

Sep 13, 2007

Hey guys what would be the easiest way to create a report of value changes for particular records from one day to the next..... ?
Any suggestions would be greatly appreciated....

thanks,
Jonathan

View 2 Replies View Related

SQL Comparison

Aug 8, 2006

Hi there! can anyone help me out??? I need to compare a date from the database and the system date which will be coded in a store procedure in SQL... HELP!!!!!

View 5 Replies View Related

Why Is My Comparison To A Bit Value Not Working?

May 21, 2008

I have a table with a field with a bit datatype. When I execute the stored procedure line if @bitvalue = 1 begin ...
and the value is passes as 0 the statements beneath the begin execute. What am I doing wrong?

View 4 Replies View Related

SQL Date Comparison

Jun 27, 2000

Hi...

I have a problem comparing dates in SQL Server 7.
I want to find results where date1 = date2.

I am having problems becausing SQL is also trying to compare the time which
is included in the field value e.g. 03/04/00 12:01:32

So even if the dates are equal the time may be different so the results are not shown?

I've tried SUBSTRING, and CONVERT,CAST etc.. and still can't get it to work

Any ideas???


Thanks.

View 1 Replies View Related

Table Comparison

Oct 3, 2000

Is there a way to compare two similar tables? I'm more interested in finding out if the data content is exactly the same or not between the two tables.

Thanks for your help.

View 1 Replies View Related

Database Comparison

Aug 19, 2003

We are converting our project into new version. They have done lot of changes in new version including normalization/denormalization. I need to compare the old and new database.
Do you have any standard script or procedure like SQL Compare software?.
Let me know what are the possibilties we need to check.
Your help appreciated.
Thanks,
Ravi

View 5 Replies View Related

Date Value Comparison

Oct 23, 2003

Good day,

I am receiving garbage data from my other department as follows.

I want:

'12/05/03' for example.

I get:

'//'
'00/00/00'

And other garbage. All of which crashes the transaction because it cannot be converted to Datetime.

What I would like to do is something like this:

IF @v_date > '01/01/50'
BEGIN <-- statement will crash if bad data)

Something to trigger a Boolean (True/False) validation of the data.

I want to know if it is even a date before I run it through my block.

Any thoughts?

I don't want to add a new IF block for every bizarre thing they send me.

Thanks ahead of time.


PS - I guess I could just raise an exception and handle it in a block that way, but am still curious.

View 3 Replies View Related

Comparison Between Columns.

Dec 11, 1998

Hi friends,

How can I do, in one Trigger, to returns if two columns, one of the Inserted and other of the Deleted, are differents ? I used this example:

If ( select Name from inserted ) !=
( select Name from deleted )
Insert Into Log_System
( Key_Mame, User_Name, Date, Field, Value, Table_Name )
Select 'COD. PROD: ' + Convert( char(10), I.Cod_Prod ),
SUSER_NAME(), GetDate(),
'Name', Convert(Char(255), D.Name ),
Convert(Char(255), I.Name), 'U', 'PRODUCTS'
From Inserted I, Deleted D

But, if one of them is Null, then the comparison result returns FALSE.

Examples:
1 - If in the Table are keeped null and the new value is different of Null
the comparison result returns FALSE.

2 - If in the Table are keeped a value and the new value is null the
comparison result returns FALSE too.


Excuse me, my English is not currently.

Thanks !

Rodney.

View 2 Replies View Related

String Comparison

May 15, 2001

Hi,

Assuming a table with a column defined char or varchar.
I have a SQL query like this :

Select * from table1 where column1='Building'

It returns the same result that

Select * from table1 where column1='BUILDING'

It is my understanding SQL Server (verison 7 or 2000, I tried on both) is lower/capital insensitive by default when it is installed. If I want SQL Server to be case-sensitive with my char or varchar columns, where can I set it?

Is it at database level or server level I can find this setting . What is the setting that control it?

Best Regards,
Alain Gagne, Lead DBA
gagnea@msagroup.com

View 3 Replies View Related

Like Comparison Problems

Jan 12, 2006

Hello im trying to run a simple query where i compare something simple like BEARING to a field in the database using this query.


Code:


SELECT table1.STK_NO, table1.STK_NO2
FROM table1
WHERE (LEN(CLEANSED_REF)>2)
AND ('BEARING' LIKE '%'+table1.CLEANSED_REF+'%')



Inside the table i can see the CLEANSED_REF field and its value is "000BEARINGBRNG000". When i run the query i get no records returned.

But if i run

Code:


SELECT table1.STK_NO, table1.STK_NO2
FROM table1
WHERE (LEN(CLEANSED_REF)>2)
AND (table1.CLEANSED_REF LIKE '%BEARING%')



The query returns the row i wanted. Can anyone tell me why this wont work the first way, but works the second?

View 4 Replies View Related

New Features And Comparison.

Aug 13, 2004

Morning!
Folks, i want some links where i could find healthy stuff regarding New Features and Compliance levels, performance comparisons, TPC tests etc about SQL 2000 and Yukon specially.
I've to submit a document regarding Top database features that shall be used for a Medical-Billing Software in plan.

Howdy!

View 2 Replies View Related

Date Comparison

Dec 28, 2005

I have two tables that I am needing to link by the tables date field. In one table the date field is defined as varchar(23). The time for this field is always zeros.
Example: '2005-12-27 00:00:00.000'

The other table is defined as datetime, and it does have the date and time in this field.
Example: 2005-12-27 08:00:35.000

The problem i am having is
2005-12-27 00:00:00.000 does not = 2005-12-27 08:00:35.000.

Because I will never have more than one record on the same date I would like to be able to only compare the date. Example 2005-12-27 = 2005-12-27

Since the fields are 2 different field types, this is giving me a problem. Could someone please help. I have tried everything I know to do.

What I really need is the a way to format the datetime fields date into a string such as '2005-12-27'.

Hopefully what i have written makes sense.

Thanks

View 3 Replies View Related

Database Comparison

Oct 4, 2006

I had an application go down yesterday...it was giving a Type Mismatch error and the support team couldn't figure it out.

My suspicion is that a field in the database got populated with a character the vb app didn't like when it renders the information.

I'd like to prove that theory...but the database is large (4gb) and I'm not sure how to do a database comparison to see where the records differ.

Anybody have a script to get me started OR some experience to share?

Thanks,

Alex8675

View 1 Replies View Related

Database Comparison

Jan 22, 2008

In management studio, is there a way to compare databases side by side?
Or would anyone know of any freeware out there that would do such a task?
:beer:

thanks in advance.

View 3 Replies View Related

Table Comparison

May 15, 2008

Hi,
I have a table in sql server 2000.I delete some rows in the table.I would like to know the differences before & after deletion. Is it possible?

View 4 Replies View Related

Comparison Of 2 Tables

Jul 13, 2013

I am doing this 2 queries, they get data from the same tables in a very different way. The new way is a lot faster but of course there are problems. There are some discrepancies in the results. Both queries produce results with more than 200.000 rows. Second one has ca. 100 rows less than the first one and some of the results are wrong (most are correct though).

My question is how do I find the differences. I did the left outer join when column a.result != b.result (lines are defined by date and ID so they should be unique).but the join gives me problematic results (some are not different at all, some differences are not in the result).so how do I find the differences between 2 queries, including missing results/rows?

View 3 Replies View Related

Data Comparison

Jul 23, 2005

I have an Employee table with 3000 records and an Excel file having themodified data of those emplyoees. Some of the data of Excel may be sameas that of table data but some may differ. EmpId is the unique field.Other than this field, other fields of Excel may have modified data.Ineed to compare the data from SQL Server table with Excel Data.I decided to write a VB Program having two recordsets,one for SQLServer and other for Excel and compare each field's value. If themodified value is found then update that to table. Is there any way tocompare in SQL Server itself?Madhivanan

View 2 Replies View Related

Database Comparison

Jul 20, 2005

I am looking for some papers/information that compare relationaldatabases such as oracle, mysql, sql server etc. I am particularlyinterested in their features such as locking mechanisms, integrityconstraints, views... Anyone know where I can find the information?Thanks,Susan

View 3 Replies View Related

Column Comparison

Jul 20, 2005

I'm in need of a sql query that I'm not sure is possible. Here is anexample of how it's laid out.employee ID Job class Last Change Date12345 x 2/1/200412345 y 1/15/200412345 z 1/1/2004We know that this person is in job class 'x' because it's the mostrecent change. Is there a way to write a query that will exclude thelines 'y' and 'z' because they are currently incorrect?I would appreciate any help I could get. Thanks

View 1 Replies View Related

SQL Server CE Comparison

Dec 29, 2005

As many of you know I've been hunting down a SQL CE alternative / embedded DB that is easily portable among handhelds.

It turns out, that without paying for some other DB, there really aren't any good ones... Unless you go GPL, and the interpretation of GPL that most are using is that your code too is GPL even though you may only Dynamically Link to their app.  I think this is likely wrong, but none the less I'm back here yet again.

What I'm looking for this time is a definition of how SQL Server CE is implemented, how it differs from a full blown DB, etc, so I can more thourally explain "why SQL CE" is an embedded DB, and how it isn't the full blown SQL Server that has a bad reputation with some.

My guess is:

SQL Server CE is implemented via DLL.  There aren't sockets etc to allow you to connect, and it operates more like an advanced hash on the file system.

Please correct me if i'm wrong, or... send me a link where I can further research.  Also, if you have another embedded DB as a suggestion, that's free of course, please point it my way.

Thanks!

View 4 Replies View Related

Range Comparison

Mar 7, 2007

How would one go about writing an expression such as:

var not in (a to g, s to z) in the expression builder to be evaluted with and iif statment

iif(var not in (a to g, s to z),var,"not in listed")

I would rather not have to write this in the SQL statement as a case statement.

View 3 Replies View Related

Comparison Query

Aug 24, 2007

Hi guys,

I'm trying to do a comparison of 2 data sets. Basically what I want is: 'where event date from event number -24 is earlier than the event date for event number -13'

To get the eventdate for the eventno's, I have the following 2 queries:

select eventdate
from caseevent, cases
where eventno = -24

select eventdate
from caseevent, cases
where eventno = -13

So what i'm trying to say is: I want it so that the value of the first query is compared to be LESS than the value of the second query...

Any help please????

Thank you!

View 11 Replies View Related

Problem With IIF And Like Comparison

May 31, 2007

I am having a problem with the following expression



=IIf(Fields!client_short_name.Value Like "Capital% ", 1,0)



I am wanting to get a value of 1 if the field has any of the valid values that begin with Capital but it always returns 0. Any ideas?

View 5 Replies View Related

Numer Comparison

Sep 27, 2007



Hi,
I have table with four fields ID, Date1, Date2,Date3,Date4. Dates are in numeric farmat like 20070927. How can i get largest date (from date1 to date4) on each row. Please suggest query.
Thanks

View 19 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved