tsql - How can i store the result of a comparison into a variable -


I want to print a simple statement print (1 = 1), I hope the result will be TRUE or 1 but the SQL Tell me the server: '=' has the wrong syntax why is this?

The same statement will be

  declare @ test bit set @test = (1 = 1)  

summary How can I "see" one comparison without using the IF statement?

Update: The reason I am asking because I am trying to debug the following statement

  declare @ agingmount small amount set @ aggingemount = 500 select amount, dated (day, batch.shmidadet, meet ()) from myreporrt anging Where as dated (day, batch.shmidadet, detet ()) gt; @ AGING AMAND  

will return all the rows along with the age of 300, so I had to find out if dated (days, dates, meetings, dot claim)> 500 returns True or false, but no way could be found to show the results of this comparison.

Although there is the concept of boolean in SQL Server, Expressions that do not support the declaration of , in boolean to if and WHERE sections, boolean < / Code> variable or parameter bit data type can not directly store the results of the boolean expression, even if it looks suspicious in a way.

The nearest you boolean the data type is:

  - Store the result of a Boolean test, declare @certif bit selection @result = Case when & lt; Boolean expression & gt; Then the end of 1 and 0-- use the above results elsewhere. If @ Roots = 1 ... and ...  

To add confusion, like SQL Server Management Studio bit as boolean When displaying the data while displaying the data, and from the ADO.NET map bit to System.Boolean .

Update: To answer your latest question, use the case when ... then 1 and 0 ends syntax select In the statement.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -