Different Query Results For Different Users?

Apr 22, 2008

I have an SQL2K5 database where a group of users share a custom database role and access the database via trusted connections (Windows authentication).

I have a stored procedure which reports all of the users in this database role using an SQL statment something like this:

select name
from sysusers
inner
join sysmembers on
sysmembers.memberuid=sysusers.uid
and sysmembers.groupuid=7

As the programmer, and the dbo, when I log in to execute this query, I get the list of a dozen, or so, users.

When one of the users executes the same query, they only see a return of their own username.

I'd like to have the users be able to execute this query and get the full list of users. Can someone tell me how to accomplish this?

I assume that this is some security, or permissions, thing involving system tables, or Windows authentication security.

Thank you.

BTW--the users never actually directly execute the stored procedure I mentioned; They are using a VB client application that affects the execution.

View 4 Replies


ADVERTISEMENT

Results From Query Are TRUE And FALSE But Users Wanting YES And NO

Jan 7, 2004

Hi everyone.

I've got a Select query that pulls out some data from my database. Two of the columns are both booleans (bit's of size 1) so they come back as TRUE and FALSE - which I thought was fine.

However, the users are wanting to see YES and NO since they find TRUE and FALSE confusing (yes I know how silly that sounds).

Is there any way I can do this?

My query is like this:
SELECT [stuff], [things] FROM [table1], [table2] WHERE [table1].[condition] = [table2].[condition]

Thanks
Andrew

View 4 Replies View Related

Submit Users ID With Results.

Mar 8, 2007

Hi
I am trying to create a Quiz system and i need to put the user's Unique ID in the Result Data Table, so that the when they submit there results it puts there Unique ID by the side so that they can view it in there profile, and not anyone elses.
 Thanks
 Gareth Cork

View 1 Replies View Related

Is It Possible To Restrict The Users To Export Report Results Only To Excel ?

Jan 2, 2007

Is it possible to restrict the Users to Export Report Results only to Excel ?

So instead of the default drop down options of csv, pdf, tiff,Web Archive,Web Archive etc... can we get it to just display Excel.

Any help would be appreciated.

View 1 Replies View Related

Is There A Way To Hold The Results Of A Select Query Then Operate On The Results And Changes Will Be Reflected On The Actual Data?

Apr 1, 2007

hi,  like, if i need to do delete some items with the id = 10000 then also need to update on the remaining items on the with the same idthen i will need to go through all the records to fetch the items with the same id right?  so, is there something that i can use to hold those records so that i can do the delete and update just on those records  and don't need to query twice? or is there a way to do that in one go ?thanks in advance! 

View 1 Replies View Related

Need To Display Results Of A Query, Then Use A Drop Down List To Filter The Results.

Feb 12, 2008

Hello. I currently have a website that has a table on one webpage. When a record is clicked, the primary key of that record is transfered in the query string to another page and fed into an sql statement. In this case its selecting a project on the first page, and displaying all the scripts for that project on another page. I also have an additional dropdownlist on the second page that i use to filter the scripts by an attribute called 'testdomain'. At present this works to an extent. When i click a project, i am navigated to the scripts page which is empty except for the dropdownlist. i then select a 'testdomain' from the dropdownlist and the page populates with scripts (formview) for the particular test domain. what i would like is for all the scripts to be displayed using the formview in the first instance when the user arrives at the second page. from there, they can then filter the scripts using the dropdownlist.
My current SQL statement is as follows.
SelectCommand="SELECT * FROM [TestScript] WHERE (([ProjectID] = @ProjectID) AND ([TestDomain] = @TestDomain))"
So what is happening is when testdomain = a null value, it does not select any scripts. Is there a way i can achieve the behaivour of the page as i outlined above? Any help would be appreciated.
Thanks,
James.

View 1 Replies View Related

Query Diff Results From Ent Manager Query And Query Analizer

May 28, 2008

ok can someone tell me why i get two different answers for the same query. (looking for last day of month for a given date)

SELECT DATEADD(ms, - 3, DATEADD(mm, DATEDIFF(m, 0, CAST('12/20/2006' AS datetime)) + 1, 0)) AS Expr1
FROM testsupplierSCNCR
I am getting the result of 01/01/2007

but in query analizer I get the result of

12/31/2006

Why the different dates

View 4 Replies View Related

Query Fails With Invalid Column Name But Succeed As Sub-query With Unexpected Results

Sep 22, 2015

-- The 3rd query uses an incorrect column name in a sub-query and succeeds but rows are incorrectly qualified. This is very DANGEROUS!!!
-- The issue exists is in 2008 R2, 2012 and 2014 and is "By Design"

set nocount on
go
if object_id('tempdb.dbo.#t1') IS NOT NULL drop table #t1
if object_id('tempdb.dbo

[code]....

This succeeds when the invalid column name is a valid column name in the outer query. So in this situation the sub-query would fail when run by itself but succeed with an incorrectly applied filter when run as a sub-query. The danger here is that if a SQL Server user runs DML in a production database with such a sub-query which then the results are likely not the expected results with potentially unintended actions applied against the data. how many SQL Server users have had incorrectly applied DML or incorrect query results and don't even know it....?

View 2 Replies View Related

Transact SQL :: Adding Results Of Query To Another Query Via Dynamically Added Columns

Jul 30, 2015

For each customer, I want to add all of their telephone numbers to a different column. That is, multiple columns (depending on the number of telephone numbers) for each customer/row. How can I achieve that?

I want my output to be

CUSTOMER ID, FIRST NAME, LAST NAME, TEL1, TEL2, TEL3, ... etc

Each 'Tel' will relate to a one or more records in the PHONES table that is linked back to the customer.

I want to do it using SELECT. Is it possible?

View 13 Replies View Related

Easy SQL Question. How To Display Query Results In Query Analyzer

Feb 12, 2008

When I run the following query from Query Analyzer in SQL Serer 2005, I get a message back that says.
Command(s) completed successfully.
What I really need it to do is to display the results of the query. Does anyone know how to do this?
declare     @SniierId as   uniqueidentifierset @SniierId = '85555560-AD5D-430C-9B97-FB0AC3C7DA1F'declare    @SniierAlias  as nvarchar(50)declare    @AlwaysShowEditButton  as bitdeclare     @SniierName  as  nvarchar (128)/* Check access for Sniier */SELECT TOP 1       @SniierName      = Sniiers.SniierName,        @SniierAlias    = Sniiers.SniierAlias,        @AlwaysShowEditButton = Sniiers.AlwaysShowEditButtonFROM SniiersWHERE Sniiers.SniierId=@SniierId

View 3 Replies View Related

How Do I Do A Query That Uses All Users?

Jul 5, 2000

Hello,

I am doing a website that incorporates SQL and one of the things is which user to query for. In this part, I would like to put
the variable 'AllUsers' which consists of all the users, do you have any suggestions on how this can be done, here is what I
have without a query for 'AllUsers' in HTML:

<SELECT NAME="targetUserID">
<OPTION VALUE="AllUsers">All Users</OPTION>
<!-- =queryString "select distinct rtrim(userID) from
Track..cUsers order by userID" -->
<!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
<OPTION VALUE= "<!-- $ $tmpuserID -->"
<!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
<!-- $ $tmpuserID --></OPTION>
<!-- ?}sqlBlock -->
</SELECT>

Here is what I thought would work, but it didn't:

<SELECT NAME="targetUserID">
<!-- =queryString "declare @AllUsers varchar(16) select @AllUsers = userID from Track..cUsers" -->
<!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString AllUsers -->
<OPTION VALUE="AllUsers">All Users</OPTION>
<!-- ?}sqlBlock -->

<!-- =queryString "select distinct rtrim(userID) from
Track..cUsers order by userID" -->
<!-- ?{sqlBlock $queryString crux 2000 0 -1 errorString tmpuserID -->
<OPTION VALUE= "<!-- $ $tmpuserID -->"
<!-- ({ $tmpuserID == $targetUserID --> SELECTED<!-- (} -->>
<!-- $ $tmpuserID --></OPTION>
<!-- ?}sqlBlock -->
</SELECT>



In case you dont like how that looks here is what I thought would work just in SQL:

declare @AllUsers varchar(16)
select @AllUsers = userID
from Track..cUsers

I also tried to do it with my query for the final information, but that didnt work either it went something like this:

select DATEDIFF( hour, startTime, stopTime), cSlice.projectID " +
from Track..cSlice, Track..cProjects
where '" + $targetUserID + "' = 'AllUsers'
and clientID = '" + $targetClientID + "'
and state = 'Stopped'
and typeID = 'Billable'
and cSlice.projectID = cProjects.projectID
and startTime like '" + $targetMonth + "%'
or userID = '" + $targetUserID + "'
and clientID = '" + $targetClientID + "'
and state = 'Stopped'
and typeID = 'Billable'
and cSlice.projectID = cProjects.projectID
and startTime like '" + $targetMonth + "%'
order by cSlice.projectID

Any help would be greatly appreciated, Thank you for your time.
Nathan Czuba

View 1 Replies View Related

Returning Results Based On One Query Into Existing Query

Aug 2, 2012

linking two tables together to get an end result

find below the code i have used

The first part of the query provides me with the info i need

SELECT sub.*,
case when rm_sales_band = '2M to 4M' then 'Kirsty' else RM end as rm
into #rmtmp

[Code].....

View 1 Replies View Related

Transact SQL :: Use Query Results As Select Criteria For Another Query

Jul 10, 2015

I have a query that performs a comparison between 2 different databases and returns the results of the comparison. It returns 2 columns. The 1st column is the value of the object being compared, and the 2nd column is a number representing any discrepancies.What I would like to do is use the results from this 1st query in the where clause of another separate query so that this 2nd query will only run for any primary values from the 1st query where a secondary value in the 1st query is not equal to zero.I was thinking of using an "IN" function in the 2nd query to pull data from the 1st column in the 1st query where the 2nd column in the 1st query != 0, but I'm having trouble ironing out the correct syntax, and conceptualizing this optimally.

While I would prefer to only return values from the 1st query where the comparison value != 0 in order to have a concise list to work with, I am having difficulty in that the comparison value is a mathematical calculation of 2 different tables in 2 different databases, and so far I've been forced to include it in the select criteria because the where clause does not accept it.Also, I am not a DBA by trade. I am a system administrator writing SQL code for reporting data from an application I support.

View 6 Replies View Related

Query All My Users Activites Only

Apr 15, 2008

This Query is returing all the Users information and more too much.
I need to only return the information that is ispecfici within that date for that particular user not tons (1,000 of records) of data. It should only be maye hundreds. HELP ME WITH QUERY PLEASE....
Query

Code:


SELECT DISTINCT
dbo.UserInfo.tp_SiteID AS SiteID, dbo.UserInfo.tp_GUID AS GUID, dbo.UserInfo.tp_ID AS ID, dbo.UserInfo.tp_Deleted AS FilesDeleted,
dbo.UserInfo.tp_Login, dbo.UserInfo.tp_Title AS Name, dbo.UserInfo.tp_Notes AS Extra, dbo.UserData.tp_Editor,
dbo.UserData.tp_Modified AS DateModified, dbo.Docs.DirName, dbo.Docs.LeafName, dbo.Docs.ListId, dbo.Docs.Type, dbo.Docs.TimeLastModified,
dbo.Docs.Extension
FROM dbo.Docs LEFT OUTER JOIN
dbo.UserData ON dbo.Docs.SiteId = dbo.UserData.tp_SiteId LEFT OUTER JOIN
dbo.UserInfo ON dbo.UserData.tp_SiteId = dbo.UserInfo.tp_SiteID
WHERE (dbo.UserInfo.tp_Login = 'HISNTsfehn') AND (dbo.UserInfo.tp_GUID = dbo.UserInfo.tp_GUID) AND (dbo.UserData.tp_Modified BETWEEN
'2008-01-01' AND '2008-04-04')

View 10 Replies View Related

I Want To Query All Users Are Member Of SYSADMIN, How To Do?

Oct 14, 2000

How to determine to a login is a member of SERVER ROLE or DB ROLE?
I want to query all users are member of SYSADMIN, how to do?

View 1 Replies View Related

How To Query Active Users - Where Is This Info Stored ???

Jul 25, 2001

I know how to look at active users from Enterprise Manager, but how can I query out the information - what table is that info stored in ??? I don't want a list of all the logins, I just want the list of active users....

Help... thanks in advance,
Nancy

View 2 Replies View Related

How To Write A Query To View OS And Db Authenticated Users ...

Aug 13, 2003

Hi,

we have a sqlserver 2000 db with a mixture of OS and NT authentication.How to write a query (or get info) on users.


The query should be able to tell me that these users are OS authentiacted and these users are db authenticated.


Thanks,
-copernicus

View 4 Replies View Related

Query Users In A Security Group With LDAP

Aug 11, 2004

I have a linked server set up and working correctly. I can create a query to get all the users from active directory with something like this:

SELECT [name], [samaccountname] from OpenQuery( ADSI,
'SELECT name, samaccountname FROM ''LDAP://DC=domain,DC=com'' WHERE objectClass = ''user'' and objectCategory=''Person''')

Now I am trying to select all the users in a specifed security group, but I am not having much luck. What is the best way to get this?

Thanks much.

View 3 Replies View Related

Query To Show Only Users Who Logged On In Past 6 M

Feb 20, 2006

Hi All

I have built this query :

Select position, SubsidiaryName
from position
Where SubsidiaryName in ('country1','country2')
and position not like('testuser_%')
and position not like ('Inactive_%')
and position not like('olduser_%');

However when I run it, the result more accounts in country 1 than expected. I think it could be inactive users who have not logged into this system for 6 months or more. How can I build a query that incorporates my original query + shows only users who logged into the past 6 months ?

View 2 Replies View Related

Own Query Language For Non-technical Users, Any Frameworks Known?

Jul 23, 2005

HelloWe have the challenge to introduce for our database applications adynmaic search for the end users. The end users are non-technicalusers.I am looking therefore for possibilities which would allow to build ownquery language with expressions according to the need and skills forthe users.I found one product so far. "EasyAsk - Decision Adviser". does somebodyknow also other tools or frameworks which can be integrated?http://www.easyask.com/product*s/decision-advisor.cfmThe environment is currently MS SQL Servers and C# Webservices.Myvision is to have a framework or library which can be seamlessintegrated into our existing solutions which is currently a smart C#clients. i.e. by using web-service or an C# API.thanks Mark Egloff

View 1 Replies View Related

Query To Obtain Users And Privileges From Databases

Apr 24, 2007

Hi to all, is my first post, i need a query or script to obtain all users and privileges from all my databases, someone to help me. I'm learning Administration SQL server 2005.



I know that sys.database_principals and sys.server_principals have information about that, but i need users - privileges of every database.



thank you

View 4 Replies View Related

Reporting Services :: Adding (new) Child Domain Users To SSRS As System Users?

Jul 28, 2015

We have an existing SSRS server, and have just created a new child domain. We'll be migrating users from the parent to the child, and want to add the users of that new domain with access to SSRS. In the parent domain they are able to access, but after migration with the child domain account, they cannot.

I have added the group CHILDDomain Users with a system user role on SSRS, and PARENTDomain Users was already there.

Is there any additional step I should/could take to get this active?

View 5 Replies View Related

Why Out Of The Blue Would VPN Users Be Unable To Connect To Database And Local Users Are Unaffected?

Mar 6, 2008

I have had this issue just pop up. I have local users who can connect fine, but my users that require connection by VPN cannot connect. I get the server not available or access denied error. I did confirm that the VPN'ers are connected to the network correctly and can see that their shares and mappings are correct. Any ideas? Thanking you all in advance!!

View 6 Replies View Related

SQL Security :: Did Not Create Any New Users And There Are No Other Users Listed In Accounts Section

Sep 28, 2015

I am trying to revert back to Windows 7 after upgrading to Windows 10, however it will not let me and the following message occurs: "Remove new accounts.Before you can go back to a previous version of Windows, you'll need to remove any user accounts you added after the most recent upgrade. The accounts need to be completely removed, including their profiles.You created one account (NT SERVICEMSSQLSERVER) Go to Settings> Accounts> Other users to remove these accounts and then try again".However I did not create any new users and there are no other users listed in the Accounts section.

View 2 Replies View Related

Query A Query With Multiple Results

Aug 22, 2005

Hi,New to .Net and SQL.  I have two tables that I have joined together.  RentalControl_Main has the rental informationd and an Adjuster ID that links to the ADjuster table and the adjusters name.  I am trying to create a report that gives the "Single" adjuster name and the totals for all of their contracts.  I have a details report that gives each contract info. for each specific adjusters rentals.  However, I want to just list the adjuster once and give all of their totals.  In my SQL statement I have all of it written out and just need to knowwhat to do in place of 'Alex Early' that will give me all of the distinct adjusters.Do I need to code this on the page with a do while loop?Appreciate any help.SELECT     SUM(dbo.RentalControl_Main.Rate) / COUNT(dbo.RentalControl_Main.Rate) AS AmtAvg, SUM(dbo.RentalControl_Main.DaysBilled)                       / COUNT(dbo.RentalControl_Main.DaysBilled) AS DayAvg, SUM(dbo.RentalControl_Main.Rate * dbo.RentalControl_Main.DaysBilled)                       / COUNT(dbo.RentalControl_Main.Rate) AS TotAvgFROM         dbo.RentalControl_Main INNER JOIN                      dbo.RentalControl_Adjuster ON dbo.RentalControl_Main.AdjusterID = dbo.RentalControl_Adjuster.AdjusterIDWHERE     (dbo.RentalControl_Adjuster.AdjusterName = 'Alex Early' AND (dbo.RentalControl_Main.DateClose IS NOT NULL) AND                       (dbo.RentalControl_Main.AgencyID = '2')

View 1 Replies View Related

Stored Procedure To Get All Users Or All Users Of A Specific Country

Apr 30, 2008

hi alli've got two tables called "webusers" (id, name, fk_country) and "countries" (id, name)
at the meantime, i've a search-page where i can fill a form to search users. in the dropdown to select the country i included an option which is called "all countries".
now the problem is: how can i make a stored procedure that makes a restriction to the fk_country depending on the submitted fk_country parameter?it should be something like
SELECT * FROM webusers(if @fk_country > 0, which is the value for "all countries"){    WHERE fk_country = @fk_country}
who has an idea how to solve this problem?

View 9 Replies View Related

Sql Query Results #?

Apr 20, 2004

I was wondering if there was a keyword that would allow you to return the number of results from a query such as (this is fake just giving an example so that someone can give me the real answer)


select TotalReturned
from table
where field=""

View 7 Replies View Related

Query Results

Oct 7, 1999

I am a beginner with SQL, so please excuse any ignorance here.

Under SQL 6.5, when executing a SELECT DISTINCT query against a table in a certain database, the results were returned alphabetized. Now, after migrating the database to SQL 7.0, the same query does not return the results alphabetized. If I add an index for the column specified in the query to the table, the results come back alphabetized. Is there any way to correct this other than adding indexes for all columns in all tables that are queried in this manner?

TIA,

Paige

View 2 Replies View Related

Same Query, Different Results

Mar 2, 2005

I am running the same exact query in SQL 2000 and I get different results. Should I try running DBCC CHECKDB and look for errors?

View 5 Replies View Related

No Query Results

Apr 30, 2008



Hi,

I have this line of code that when run in the query doesn't return anything:

srv.AGENT_S_ACC_CODE IN ('" & Replace(Replace(Parameters!arcode.Value," ",""),",","','") & "')
The parameter is setup and the query works when I hardcode it with a value but will not return anything with this, does anyone know why?

Thanks,
Rhonda

View 2 Replies View Related

Restrict Query Results

Oct 25, 2006

Hi guys, say i wrote a query that returns 1,000 records.. what kinda query could i write that only returns say the first 50 records of the 1,000 recs..

View 4 Replies View Related

Use Results From First Query As Parameter In Second

May 13, 2007

Hello,
I want to select all the customerIDs where an email address exists. Easy: select customerid from customers where emailaddress = @emailaddress
Now I want to use the resulted customerIDs from the above query as a parameter to select all the email addresses with emailstatus equal to 3.
How do I create this type of while statement in a stored procedure? I prefer to not create a temporary table.
My idea was to do it like this:
select emailaddress from emailaddresseswhere emailstatus = 3 and customerid = (select customerid from customers where emailaddress = @emailaddress)
This doesn't seems to work. I get the error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
thanks

View 4 Replies View Related

Help Grabbing Top Three Results From A SQL Query!

Jul 17, 2007

I have a pretty big SQL query with a one to many sort of relationship...
There are client accounts that we're reporting on.  Each account has four different historical categories attached.  Each historical category can have maybe fifty entries in each, sorted by date.
I need to figure out how to grab the unique accounts and show only the three most recent results per each historical subcategory with the account...   the three most current results from each of the four subcategories, displayed by the parent client account number.
I've created four views to isolate the subcategories as a start, thinking I could bring them into a parent query ...
but my question would be... how do I generate JUST the top three historical transactions by account number?  If I select TOP 3, I get only the 3 newest in the MASTER LIST, not per client account, which is what I need to do.
Does this make sense?  I could really use a good SQL helping hand with this one.
Thank you!

View 12 Replies View Related







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