List All Of A Set Of Rows When Only One Row Is True

May 3, 2007

This is stupid, I used to be able to do this all the time by mistake now I can't do it on purpose

I want to be able to return a full list of matching records when only one is true

Like
Row 1, ID_1, false
Row 2, ID_1, false
Row 3, ID_1, true
Row 4, ID_2, false
Row 5, ID_2, true
Row 6, ID_2, false

I currently get
Row 3, ID_1, true
Row 5, ID_2, true



 

 

 

 

View 3 Replies


ADVERTISEMENT

Analysis :: Cube Dimension With Bool Filter Shows (blank) And True Instead Of False And True?

Jul 31, 2015

I have a cube that has a Dimension set up with several values some of which are bools. While Browsing in Excel or SSMS, two new values, when used as a filter shows (All) (Blank) and (True) for selections instead of (All) (True) and (False).Β 

View 2 Replies View Related

Report Designer: Need To List Fields From Multiple Result Rows As Comma Seperated List (like A JOIN On Parameters)

Apr 9, 2008



I know I can do a JOIN(parameter, "some seperator") and it will build me a list/string of all the values in the multiselect parameter.

However, I want to do the same thing with all the occurances of a field in my result set (each row being an occurance).

For example say I have a form that is being printed which will pull in all the medications a patient is currently listed as having perscriptions for. I want to return all those values (say 8) and display them on a single line (or wrap onto additional lines as needed).

Something like:
List of current perscriptions: Allegra, Allegra-D, Clariton, Nasalcort, Sudafed, Zantac


How can I accomplish this?

I was playing with the list box, but that only lets me repeat on a new line, I couldn't find any way to get it to repeate side by side (repeat left to right instead of top to bottom). I played with the orientation options, but that really just lets me adjust how multiple columns are displayed as best I can tell.

Could a custom function of some sort be written to take all the values and spit them out one by one into a comma seperated string?

View 21 Replies View Related

Return Only The Rows From A List That Has The Same Value From One Field

Aug 2, 2006

I am in need of help to develop a query
I have two tables Exams and Exams_lab, that are joined by a field id_exame. I want to return The Exams that has all the dependent rows in Exames_lab with the same value in the status_int field of Exames_lab. Can anyone Help Me?
Lets see an example
tb_exame



id_exame
date_exame

1
07/01/2006

2
08/01/2006

3
09/01/2006
tb_exame_lab



id_exame_lab
id_exame
desc_exame
status_exame

1
1
NORMAL
1

2
1

0

3
2
NORMAL
1

4
2
PROBLEMS
1

5
2
OK
1

6
3
OK
0
in this exemple my query must return only id_exame 2 and 3 because id_exame 1 has two different values on id_status on tb_exame_lab
can anyone help me?
 

View 5 Replies View Related

Combining Like Rows If More Than One UserID In The List

Jun 6, 2014

I have the following query:

Code:
SELECT DISTINCT [WL].[Id]
,[WL].[UserId]
,[WL].[DIF]
,[WL].[MW]
,[WL].[Notes]
,[WL].[WDate]

[Code] ....

And the error i get is:

> Column 'Wsite.dbo.WLog.Id' is invalid in the select
> list because it is not contained in either an aggregate function or
> the GROUP BY clause.

What I am wanting to do is just conbine the data if there are more than one **UserID** in the list.

As an example:

Code:
Id | UserId | .... | Id | UserName | SLength | ....
5843| 99304 | .... | 99304| Bob Barker | 14 | ....
5844| 06300 | .... | 06300| Dean Martin | 104 | ....
5845| 99304 | .... | 99304| Bob Barker | 8 | ....
5846| 99304 | .... | 99304| Bob Barker | 11 | ....
5847| 7699 | .... | 7699 | John Doe | 0 | ....

So it should look like this:

Code:
Id | UserId | .... | Id | UserName | SLength | ....
5843| 99304 | .... | 99304| Bob Barker | 33 | ....
5844| 06300 | .... | 06300| Dean Martin | 104 | ....
5847| 7699 | .... | 7699 | John Doe | 0 | ....

Notice that Bob Barker's SLength was combined (14+8+11=33).

View 1 Replies View Related

Find And List Duplicate Rows

Oct 17, 2013

I'm using this to find duplicates where a person has the same email but varying firstname and lastnames:

select distinct t1.booking_id, t1.first_name, t1.last_name, t1.email_add, t1.booking_status_id
from [aren1002].[BOOKING]
as t1 inner join [aren1002].[BOOKING]
as t2
on t1.last_name=t2.last_name and t1.booking_id<>t2.booking_id
where t1.booking_status_id = 330
order by last_name asc

Sample data:
3927 Greg Smith greg@emailno1.com 303
5012 John Smith greg@emailno1.com 303
6233 John Smith greg@emailno1.com 303
4880 Dulcie Abuud dulcie@theiremail.com 303

However it is listing the non duplicate rows, For example: The record with Abuud as the last name, doesn't have any duplicates in the table, so I don't want it listed.

The data should be like this:
3927 Greg Smith greg@emailno1.com 303
5012 John Smith greg@emailno1.com 303
6233 John Smith greg@emailno1.com 303

View 4 Replies View Related

List Of Rows With Same Column Values

Nov 3, 2014

select pr.birthdate, pr.operationdate from patientrecord pr
Total no.of rows = 24420

select distinct pr.birthdate, pr.operationdate from patientrecord pr
Total no.of rows = 23528

It seems there are some rows with same birthdate and operationdate.

I want to get the list of rows(with all columns) that has got same birthdate and operationdate

View 1 Replies View Related

T-SQL (SS2K8) :: Query To List Rows Into Columns?

Aug 10, 2015

I have requirement to list each row into column. I have tried with pivot query but unable to get it. I am using SQL Server 2008 database.

Here is the sample data:

CREATE TABLE dbo.test (
action_id numeric,
action VARCHAR(20) NOT NULL,

[Code].....

View 3 Replies View Related

(URGENT) Getting The Number Of Rows From List Control

Oct 16, 2007

Ok here is what I have

Department:A

Line 1 Name: George
Addresss date raise
125254 Test 10
125254 Test 10
125254 Test 10
125254 Test 10

Total: 80% 40


Name: Mik
Addresss date raise
125254 Test 10
125254 Test 10
125254 Test 10


Total: 70% 30


Name: Jonathan
Addresss date raise
125254 Test 10
125254 Test 10
125254 Test 10


Total: 70% 30
Line 10



Line 15 Total for this division: 33% ((100 )/3) 100


Department:B
€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦€¦..
Here is what I did I have a list control that is grouped by department. this will get me the info from Line 1 to Line 10 then this list control is actually under another list control that is grouped by department to get the info from Line 15. I used this example for simplicity and what I am doing is fairly similar to this situation. My problem is, I need to find away to know how many totals I have to count the total for the entire department. In other words : from the example above how can I know I have to divide by 3 to get 33%. I can get the 100 without any problem but I can€™t tell what number I need to divided by. I tried to use Count(Name.Field) I was hoping this will give me 3 which indicates the divided number. But I was getting 7 for some reason.
How can I get the number of times the list control was implemented for one department which is in this case 3?

thanks

View 2 Replies View Related

How To Select Multiple Rows As Comma Separated List?

Jul 4, 2004

Hi,

I have a table of users, a table of categories, and a many-to-many table linking users to categories.

My problem is that I want to select all the users with an extra column containing a comma-separated list of the categories they belong to.

Here is a stripped-down version of the table fields:

tbl_User
UserId, Email

tbl_Category
CatId, CatName

tbl_User_Category
UserId, CatId


I have tried using the coalesce function to build a string, but can only get this to work for one row at a time:

DECLARE @list nvarchar(100)

SELECT @list = COALESCE(@list + ', ', '') + CAST(CatId AS varchar(4))
FROM tbl_User_Category
WHERE UserId = @UserId

SELECT @list as List


Any ideas on how to add to this to get it to do each row in tbl_Page? Or am I attacking this from the wrong angle?????

Any help would be fantastic!

thanks,
Rob

View 4 Replies View Related

SQL 2005 Return A List Of Missing Rows By Date?

Feb 12, 2008

Hi,

I have written a reporting application which has a SQL2005 backend. An import routine into SQL, written by a 3rd party, frequently fails. The main problems are missing rows in certain tables.

I am going to write an SP that will accepts a from and to date. I then want to search for rows of type X between those dates that do not exist so we then know between a date range, we have no data for these XYZ days.

I have this working by returning all rows between the dates into a dataset, sorted by date, and then running through the rows and testing if the next rows date is the next expected date. This works but I think is a very poor solution. This is all done on the client in C#.

I want to learn and implement the most efficent way of doing this. My only solution in a SP was to make a temporary table of all dates between the date range for row type X and then do a right outer join against the data table, returning all rows which are missing.

Something like this:

SELECT twmd.date
FROM #temp_table_with_all_dates ttwad
RIGHT OUTER JOIN table_with_missing_date twmd
ON ttwad.date = twmd.date
WHERE twmd.date IS NULL

Would this be a good, efficent solution, or should I just stick to my processing of a dataset in C#?

Many thanks in advance,
CB

View 4 Replies View Related

Insert Into Multiple Rows Instead Of One Comma-delimited List?

Jul 20, 2005

Hi, all:I have a form which lets users choose more than one value for each question.But how do I insert each value as a separate row in my table (instead ofhaving the values submitted as a comma-delimited list)?Thanks for your help.J

View 2 Replies View Related

SQL Server 2012 :: List Catalog Reports With No Execution History Returns 0 Rows

Feb 13, 2015

comparing UNIQUEIDENTIFIER columns..This query returns several rows where the [ReportId] and [LastRunDate] columns are both NULL:

SELECT [c].[Name],[c].[ItemID],[xl].[ReportID]
, MAX([TimeStart]) [LastRunDate]
FROM [dbo].[Catalog] [c]
LEFT JOIN [dbo].[ExecutionLogStorage] [xl] on [c].[ItemID] = [xl].[ReportID]
WHERE [c].[Type] NOT IN (1,5) -- Not a folder or a data source!
group by [c].[Name],[c].[ItemID],[xl].[ReportID]
order by 4

However, trying to just list catalog reports with no execution history returns 0 rows, but I'm expecting it to return a row for every NULL [ReportId] from the above query:

SELECT *
FROM [dbo].[Catalog]
WHERE [Type] NOT IN (1,5) -- Not a folder or a data source!
AND [ItemID] NOT IN (SELECT [ReportID] FROM [dbo].[ExecutionLogStorage])

I even tried casting [ItemId] and [ReportId] columns in the 2nd query to VARCHAR(255), and still got no rows, but the following queries return 0 rows and 1 row (respectively).

select * from [dbo].[ExecutionLogStorage] where [ReportID] = '0BB2209C-7736-46C8-AD02-4614EBA4F0F1'
select * from [dbo].[Catalog] where [ItemID] = '0BB2209C-7736-46C8-AD02-4614EBA4F0F1'

View 4 Replies View Related

Reporting Services :: How To Display Fixed Number Of Rows In Page Wise Using List

Sep 10, 2015

i want to break 2 by 2 rows in reportceiling(rownumber(nothing)/2).i used this expression in row group.Β URL....but i want to use this expression in matrix and that matirx is with in list . so i Β am getting error .Β how to use rownumber in list.here i used list to break the page wise id

View 3 Replies View Related

Transact SQL :: Get Multiple Rows Based On Comma-separated Ntext List In On Column?

Jun 2, 2015

I have a table that is used to build rules. The rules point to other columns in other tables and usually contain only one value (i.e. ABC). But one of the options is to add a comma-separated list of SSNs (i.e. 123123123,012012012,112231122).Β  I am trying to build a single query that allows me to leverage that list to get multiple rows from another table.

This obviously works:

SELECT * FROM vw_Person_Profile P (NOLOCK)
WHERE P.PrsnPIISSN_Chr IN ('123123123','012012012','112231122')

But this does not:

SELECT * FROM vw_Person_Profile P (NOLOCK)
WHERE P.PrsnPIISSN_Chr IN (
SELECT '''' + REPLACE(CONVERT(VARCHAR(4000),txtFieldValue), ',', ''',''') + ''''
FROM MassProcessing_Rules PR
WHERE PR.intRuleID = 10
)

View 5 Replies View Related

Is It True?

Jul 7, 2006

Microsoft E-Learning products are currently available for purchase only within North America at this time

Jezz, bad luck I am currently living in Spain...

View 1 Replies View Related

In A Where How Can I Use True Or False

Oct 20, 2007

I have a stored procedure that has a boolean (bit) field passed to it (@emailcontract). If a user checks the check box on the webform I would like my where to return only the records where the email_contract column is true. If they don't check the check box I would like it to return records where email_contracts is true or false.
What would my where cluse look lile for this?

View 4 Replies View Related

If True GO ON Else END PACKAGE

Oct 16, 2006

I am designing a package performing some data imports from a text file to some tables, passing by a temporary table.
My specific requirements are:
initially the package checks if the input file exists, if it doesn't it will not continue.I have implemented this with a Script Task, and if the
file doesn't exist I fail the all package (Dts.TaskResult =
Dts.Results.Failure). Is this the right way?

after copying the data into a temporary table, it checks via SQL if some conditions are verified, if not it will not continue.I would have liked to do it via an SQL Task, but I don't know how to stop the package if the conditions are not what expected. Anybody can help?

Thank you.

View 2 Replies View Related

True False

May 13, 2007

All



Can I ask what data type i use for a true false response (Boolean) in my table?



Thanks



Gibbo

View 1 Replies View Related

How To Return True If A Sql Row Exists

Mar 10, 2008

 Hi all, I am trying to access a sql database and if the userid exists in the database to the let me query another statement within an IF block to check another statement within the data, however I cannot seem to get it to work. I need something like sql.row.count != 0 within  the 2nd IF statement below. What can I do?Thanks in advance.Jason   using System;using System.Configuration;using System.Data;using System.Data.SqlClient;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;public partial class _Default : System.Web.UI.Page {    protected void Page_Load(object sender, EventArgs e)    {            }    protected void btnStart_Click(object sender, ImageClickEventArgs e)    {        if (Session["userid"] == null)        {            Response.Redirect("accessdenied.aspx");        }        else        {            //Response.Redirect("page1.aspx");            SqlConnection objConnect = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);            objConnect.Open();            SqlCommand cmd = new SqlCommand("SELECT user_id FROM users WHERE user_id = '" + Session["userid"] + "'");            if (cmd == true)            {                Response.Redirect("page5.aspx");            }            objConnect.Close();        }    }} 

View 7 Replies View Related

What Is The Trusted_Connection=true Parameter?

Feb 9, 2004

what does this imply Trusted_Connection=true parameter in the Connection String signify?
Secondly how can I make users with Windows Authentication Login to work in SQL Server Connection String?


Thanks in advance,

Neeraj.

View 1 Replies View Related

Trunc. Log On Chkpt. Is True

Mar 17, 2006

hi

I just created a DB , & ran sp_dboption , it showed me that the trunc. log on chkpt. is true .....

What if i set the recovery model of this DB to full , would I be able to recover the DB to a specific point in time ,
or since trunc. log on chkpt. is true.. I would not be able to collec the transaction log backups ???

Cant understand this concept , need some link to read this stuff ....


Thanks

View 1 Replies View Related

Return True False

Mar 20, 2008

Hi,
I need to check the existence of a row in a table.
So i am using an if condition
like
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[CheckNOAStages]
@NOAID int,
@StageCode nchar(20)
AS
BEGIN

SET NOCOUNT ON;
Declare @Count int
Select @Count =Count(NOAId) from NOAStages where NOAID=@NOAID and StageCode=@StageCode
if (@Count>0)
Begin
return 1
end
else
begin
return 0
end


END

The stored proc is executing but on the Data Access Layer
I have this
Boolean exists = Convert.ToBoolean (Execute.ExecuteReader(spCollection, dbSQL));

Some how I am always getting false . How can I fix this?
Thanks

View 7 Replies View Related

Job Ends Successfully Even When It's Not True

Apr 23, 2008

Hi,
we've got this problem with some particular jobs: they look as they
ran correctly, but actually they didn't made it all through their
duties.
The problem is that this job is calling a sequence of DTS, where there
is a DTS with an ActiveX control which modifies another DTS before
launching and some other tasks: the error happens there, .
Launched from the DTS we get the error, from the job no...any idea how
we could get the correct job information?
Thank you
Daniele

View 5 Replies View Related

How To Change From True Or False To 1 Or 0

Oct 29, 2007



Hello

I am exporting an SQL Server table to a comma delimited text file. The values of Columns defined as Bit are exported as "True" or "False", but I would like that in the file appear 1 or 0 instead (with no surrounding double quotes). How can I acomplish that?

I tried using a Transformation and convert to single byte unsigned integer, but True values are exported as "255" and False values as "0". Why?

Thanks a lot.

View 1 Replies View Related

How To Set This Parameter AlwaysUseDefaultCodePath=TRUE

Sep 24, 2007

Hello all,
I am trying to migrate date from Oracle 10g to SQL serve 2005 during the data transformation I get the following error



Messages

Warning 0x80202066: Source - SERVICE [1]: Cannot retrieve the column code page info from the OLE DB provider. If the component supports the "DefaultCodePage" property, the code page from that property will be used. Change the value of the property if the current string code page values are incorrect. If the component does not support the property, the code page from the component's locale ID will be used.
(SQL Server Import and Export Wizard)




I searched internet and solution seems to be setting AlwaysUseDefaultCodePath="TRUE"


But where do you do this ?


I found this too: It's on the Properties tab of the OLE DB Source in Custom Properties section.


But still do not know where to go to set this parameter

Please help

View 4 Replies View Related

Trying To Insert Checkbox True/false Into Db

Aug 15, 2005

Hi there, I've tried googling this (and looking at the many questions on the forum :) but I've not managed to find a decent tutorial / guide that describes a method for using checkboxs to insert true/false flags in a MS SQL db.  The db field i'm setting has type set to "bit", is this correct?  And secondly (its been a long day!) I just cant figure out the code to assign the bit 1 or 0 / true or false. This is what I've got so far but it's not working........Function InsertProduct(ByVal prod_code As String, ByVal prod_name As String, ByVal prod_desc As String, ByVal prod_size As String, ByVal prod_price As String, ByVal prod_category As String, ByVal aspnet As Boolean) As Integer             Dim connectionString As String = "server='server'; user id='sa'; password='msde'; Database='dbLD'"             Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)                 Dim queryString As String = "INSERT INTO [tbl_LdAllProduct] ([prod_code], [prod_name], [prod_desc], [prod_size], [prod_price], [prod_category],[aspnet]) VALUES (@prod_code, @prod_name, @prod_desc, @prod_size, @prod_price, @prod_category, @aspnet)"             Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)                 sqlCommand.Parameters.Add("@prod_code", System.Data.SqlDbType.VarChar).Value = prod_code             sqlCommand.Parameters.Add("@prod_name", System.Data.SqlDbType.VarChar).Value = prod_name             sqlCommand.Parameters.Add("@prod_desc", System.Data.SqlDbType.VarChar).Value = prod_desc             sqlCommand.Parameters.Add("@prod_size", System.Data.SqlDbType.VarChar).Value = prod_size             sqlCommand.Parameters.Add("@prod_price", System.Data.SqlDbType.VarChar).Value = prod_price             sqlCommand.Parameters.Add("@prod_category", System.Data.SqlDbType.VarChar).Value = prod_category                 If chkAspnet.Checked = True Then                sqlCommand.Parameters.Add("@aspnet","1")             Else                sqlCommand.Parameters.Add("@aspnet","0")             End If                     Dim rowsAffected As Integer = 0             sqlConnection.Open             Try                 rowsAffected = sqlCommand.ExecuteNonQuery             Finally                 sqlConnection.Close             End Try             Return rowsAffected         End Function             Sub SubmitBtn_Click(sender As Object, e As EventArgs)            If Page.IsValid then                InsertProduct(txtCode.Text, txtName.Text, txtDesc.Text, ddSize.SelectedItem.value, ddPrice.SelectedItem.value, ddCategory.SelectedItem.value, aspnet.value)                Response.Redirect("ListAllProducts.aspx")            End If    End SubAny help would be appreciated or links to tutorials.ThanksBen

View 2 Replies View Related

Trusted_connection=true, Login '(null)'

Mar 31, 2006

When accessing a web application from an intranet....
And the web app tries to make a connection to a 'SQL Server' using the sqlconnection where does ASP.NET grab user credentials?
My webpage displays web security.principal.windows.getcurrent = domainUser  (displays the correct information).
But the connection to sql says Null.  Where is ASP.NET grabbing (retrieving) this information from?
Thanks,

View 3 Replies View Related

OR-statement Returns True CHARINDEX Instead Of Name LIKE

Jun 11, 2013

I have this OR in a simple query:

Code:
DECLARE @searchString nvarchar(100)
SET @searchString = 'sample'
SELECT TOP(1) * FROM user
WHERE (user.identity LIKE @searchString OR
CHARINDEX(@searchString, user.firstname + ' ' + user.lastname) > 0)
PS: Handwritten...

If I pass in a searchString that matches the Identity and a different users lastname, this query will return the user with the lastname-match (which is wrong in my eyes, it should have matched the Identity first, then returned that row [Identity is a Primary key, indexed non-clustered]).

I've tried various things:
Removing LastName: (CHARINDEX(@searchString, user.firstname + ' ') > 0), then the returned row is from a matching identity, due to the lastname of a user was a match, but lastname was removed...so :P
Flipping the conditions around
Adding/removing paranthesis... without any luck.

Is there some option somewhere, to force the OR statement to return on the first true condition. I've always thought OR-statements (in a computer that is) breaked and returned true on the first true condition it found (from left to right, not bother to check the rest of the conditions...)?Or do I have to rewrite the query, with an IF, checking if the @searchString is a valid identity-format, if it is, query on the identity, if not query on the username...?

View 12 Replies View Related

Send Mail True Sproc

Jan 30, 2004

Hi all,

I have a database filled with contracts, suppliers and administrators who administrates those contracts.

I want to make a sproc that checks the difference between the expiration_date and the current date(in months). the sproc compares this output with a given period in the contracts-table. when the output <= the given period ---> send mail to the administrator with info about the contract. and that the contract will be expired in X months.

Having a Sproc that only gets the info from the tables and compares this info is no problem, but to let the sproc send an email to the admin whose email-adress also comes from a table is a little bit to tricky for me.

I have searched the internet but i can't figure it out.

If anyone knows where I can get more info about this subject please be so kind and let me know, or anything that could help me around for the moment.

PS. I'm using SQL server 2000

Thnx in advance

StylizIt

View 12 Replies View Related

How Transaction Return True And False

Jun 10, 2008

Sir

I want to Return 1 and 0 after update , delete , Insert statement

IF Records Effected Return 1 else return 0

Pls help me out .........Sir

Yaman

View 4 Replies View Related

SQL Server Thinks True Is A Column Name

May 12, 2007

Hello SQL Server Experts,

I'm upgrading an application that uses a VBScript/ASP front-end and MS Access Backend. The application has many points expecting fields to be true or false..

E.g. SELECT * FROM MyTable WHERE Active=True

However, since SQL Server requires 0 or 1 for bit fields, this query keeps failing. SQL Server (2005 Express) thinks True is a column name and is not automatically converting "True" to 1.

It would be so difficult to re-write the application to do this at the VB level, is there a way to make SQL server do this conversion automatically ?

Thanks for any assistance available.

Sunny

View 1 Replies View Related

What Is The True Definition Of Catalog Table?

Jul 23, 2005

We hear about catalog table in documentation but is this the same asdatabase schema?What is the definiation of catalog table?What does it pertain to?Thanks--Message posted via http://www.sqlmonster.com

View 1 Replies View Related







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