Showing posts with label users. Show all posts
Showing posts with label users. Show all posts

Friday, March 30, 2012

Jump to Url

I use the "jump to url" in a report that links out to a page on our company intranet. Our internal users have to use http and an external user needs to be routed to the site w/ https. How can I account for this in a report?

You could use an expression for the URL and look at the global "UserID"

Based on that UserID, you should be able to determine if the user is internal or external, and set the URL appropriately.

HTH

BobP

|||

Hi Bob,

Thank you so very much for your reply. I have posted this question many times and this is the first time that I have gotten any suggestions. I am not sure if this will work in our case or not. I believe that we are using Active Directory. I am not sure if the user id actually changes when they are viewing something from here or out in the field. I have to check with my team members to see if this would work in our situation.

|||User ID will not help us to determine which site they came in on are there any other suggestions for this?sql

Jump to Url

I use the "jump to url" in a report that links out to a page on our company intranet. Our internal users have to use http and an external user needs to be routed to the site w/ https. How can I account for this in a report?

You could use an expression for the URL and look at the global "UserID"

Based on that UserID, you should be able to determine if the user is internal or external, and set the URL appropriately.

HTH

BobP

|||

Hi Bob,

Thank you so very much for your reply. I have posted this question many times and this is the first time that I have gotten any suggestions. I am not sure if this will work in our case or not. I believe that we are using Active Directory. I am not sure if the user id actually changes when they are viewing something from here or out in the field. I have to check with my team members to see if this would work in our situation.

|||User ID will not help us to determine which site they came in on are there any other suggestions for this?

Monday, March 26, 2012

JScript Error when printing / exporting

I have one user who can't print or export a report. For over 100 other users, they are not having this issue.

This one user gets:

MicrosoftVisual Studio Debugger

Microsoft JScriptruntime error: Object doesn't support this property or method

...then another IE modal error of:

IE cannot download Format=EXCEL from "domain name"

IE was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.

The user is on IE 6, sp2 which is a standard browser for all users.

Okay..finally found out the issue:

User had to install the ActiveX control when first viewing the reports!!!!!!!!!

Friday, March 23, 2012

Joins

I have two tables, one called users and the other resources.
I'd like to select several fields from users and one from Resource (called ResourceID) based on certain criteria.

My sql statement looks like this:

gstrSQL = "Select UserNum, ResourceID, UserFName, UserLName, Password, SecurityLevel, email, Telephone, ext, UserID from Users U, Resource R where "

If UserNum <> "" Then
gstrSQL = gstrSQL & "UserID='" & UserNum & "' And u.userfname = r.fname and u.userlname = r.lname"
Else
gstrSQL = gstrSQL & "UserID='" & UserID & "' And u.userfname = r.fname and u.userlname = r.lname"
End If

Before adding "ResourceID" to the selection criteria, this statement was working just fine. It's probably a silly mistake but I can't figure it out.
Thanks.You didn't let us know the DB you're working on, nor the error itself ...

In Oracle you can NOT name your table "Resource" as it is reserved word.

However, if your DB allows it, try to rewrite the query in a way to put table aliases in front of table columns, i.e.

SELECT u.UserNum, r.ResourceID, u.UserFName, ...
FROM Users U, Resource R
WHERE ...

Perhaps your tables contain the same column names and, if you don't explicitly say the table you are selecting its value from, the column becomes ambigously defined.

Joining Two Tables

I've been trying to think about how I can do this. I have forums that I have written built around SQL Server. Basicly you have:

-A users Table
-A Posts Table
-A Replies Table.

Posts and replies have very similar structures. I'd like to be able to merge them and pick out the earliest post for said forum.

1 - is there a way to merge them so that the post date for both the replies and posts tables is contained in 1 column. If not is there a better alternative.

I'd also like to add indexing to the posts so I can do paging. Is there a way for me to add an index number to them while I can sort them anyway i want.Yes. You can use the UNION operator to create the reultset you are looking for. See BOL for details, but basically:

SELECT UserID, PostTitle AS Title, PostDate AS PostDate
FROM Posts
WHERE UserID = @.UserID

UNION

SELECT UserID, ReplyTitle AS Title, ReplyDate AS PostDate
FROM Replies
WHERE UserID = @.UserID

ORDER BY PostDate DESC

(...or something along those lines; haven't UNIONed in quite a while...)sql

Friday, March 9, 2012

JOIN without excluding non-joined rows?

Good morning, folks. I'll get right to the point.

I have an MSSQL db with 3 tables. Table A holds users' data with logins and such. Table B holds workstations with machine names, hardware info, etc. Lastly, Table C holds record IDs from A and B in order to keep track of workstations paired to users. Some workstations don't have users yet, some users don't have workstations yet.

HOWEVER, I need to display all users WITH their workstations, but that same result set needs to include users which may not have a workstation associated with them

My current join query works beautifully, but does NOT include users with no workstations associated with them per Table C.

Table A is lan_user
id_user user_name user_login

Table B is lan_ws
id_ws ws_name ws_model operating_system

Table C is lan_userws_rel (as in, "relationships")
id_userws_rel ws_id user_id

select lan_user.*, lan_userws_rel.*, lan_ws.* from lan_user INNER JOIN lan_userws_rel ON lan_user.id_user = lan_userws_rel.user_id INNER JOIN lan_ws ON lan_ws.id_ws-lan_userws_rel.ws_id

Some additional information:
Workstations can have multiple users and vice versa, but I only really need one pairing in my result set - doesn't matter which one.You should use LEFT JOIN but be aware when you will use a WHERE-clause on the 'not present' items
Info from books online (the guide in troubled moments!)

Joins can be categorized as:

Inner joins (the typical join operation, which uses some comparison operator like = or <>). These include equi-joins and natural joins.

Inner joins use a comparison operator to match rows from two tables based on the values in common columns from each table. For example, retrieving all rows where the student identification number is the same in both the students and courses tables.

Outer joins. Outer joins can be a left, a right, or full outer join.

Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:

LEFT JOIN or LEFT OUTER JOIN

The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.

RIGHT JOIN or RIGHT OUTER JOIN

A right outer join is the reverse of a left outer join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table.

FULL JOIN or FULL OUTER JOIN

A full outer join returns all rows in both the left and right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.

|||{ :-O

Sweet mother of god. LEFT JOIN did essentially just what I needed.

This is proof that I have so, so much to learn about SQL. For the record, I really did look into this before posting, but I sometimes get lost in the examples given in my books.

THANK YOU.

Here was my final query:

select lan_user.*, lan_userws_rel.*, lan_ws.*
from lan_user
LEFT JOIN lan_userws_rel on lan_user.id_user = lan_userws_rel.user_id
LEFT JOIN lan_ws on lan_ws.id_ws = lan_userws_rel.ws_id
ORDER BY id_user

Monday, February 20, 2012

Join problem

Hi

CREATE TABLE [dbo].[Users](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserName] [nvarchar](50) NULL
) ON [PRIMARY]

INSERT INTO [dbo].[Users] VALUES('Unal')
INSERT INTO [dbo].[Users] VALUES('Volkan')
INSERT INTO [dbo].[Users] VALUES('Duygu')
INSERT INTO [dbo].[Users] VALUES('Elif')
INSERT INTO [dbo].[Users] VALUES('Mehmet')
INSERT INTO [dbo].[Users] VALUES('Demir')


CREATE TABLE [dbo].[Agenda](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ActivityName] [nvarchar](50) NULL,
[UserId] [nvarchar](50) NULL
) ON [PRIMARY]

INSERT INTO [dbo].[Agenda] VALUES('school excursion','1,3,4')
INSERT INTO [dbo].[Agenda] VALUES('party','6,2,3,1')

Table Name : Users

Id UserName

1 Unal

2 Volkan

3 Duygu

4 Elif

5 Mehmet

6 Demir


Table Name : Agenda

Id ActivityName UserId

1 school excursion 1,3,4

2 party 6,2,3,1


I want to join Users table with Agenda table.

The Result has to be like below:

Id ActivityName UserId UserNames

1 school excursion 1,3,4 Unal, Duygu, Elif

2 party 6,2,3,1 Demir, Volkan, Duygu, Unal

How can I do it in SQL 2005. I don't want use cursor.

OR

if I can't do that join, I have to do other join that it's below.

Id ActivityName UserId UserNames

1 school excursion 1 Unal

1 school excursion 3 Duygu

1 school excursion 4 Elif

2 party 6 Demir

2 party 2 Volkan

2 party 3 Duygu

2 party 1 Unal

thanks so much for help

What you are attempting to accomplish is a form of denormalization. While it is not a 'straightforward' task in T-SQL, here are links to a couple of approaches that may work for you.

Lists -Field Concatenation, One Field to Itself for string
http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/07/06/871.aspx
http://www.projectdmx.com/tsql/rowconcatenate.aspx

|||
Thanks everbody who help and answer.

join multi server

hi,

consider this:

i have american users in a db called "user" in a server called AMERICA

and rest of the world users in a db called "user" in a server called OTHER

how can i do a join betwhen American's users and Rest of the word's User db?

SELECT *

FROM AMERICA.user.dbo.MyTable t1

JOIN OTHER.user.dbo.MyTable t2 ON t1.id=t2.id

|||Make sure you have set uplinked server to the remote SQLSmile|||ok many thanks, it will be very usefull for my