Query adjustment

Hi There,

Can you help please.
I have a query that is used to create a report.
The report prints fine but I now need to adjust it to print based on a user type, which it doesn't currently do.
At the moment the table that the query uses has a field with a users name in it. I'll call this field1
I need to adjust the query.
Using the name in field1 I would like to look up the corresponding person in the user file. The users file has a field called UserType and based on this value I would like to include it in the report or not.

Does that make sense?
Thanks for the help.

Best Regards,

Steve

I assume by "user file" you mean table.

Please provide:

  • table descrription in form of create statement
  • sample data in form of insert statement
  • your current query
  • expected output (from the sample data you provide)

Hi There,

Thanks for the reply.

Yes, sorry it's a table called user.

CREATE TABLE [dbo].[Tbl_User](
[AutoId] [bigint] IDENTITY(1,1) NOT NULL,
[UserName] nvarchar NULL,
[TypeId] [int] NULL
) ON [PRIMARY]

Thanks.

Best regards,

Steve.

Do you really need BigInt for your UserID? BigInt takes up twice as much space - so that's only 50% of the index entries, per page, which impacts on performance.

An Integer will store 2,147,483,647 entries - twice that number if you use Negative as well as Positive numbers - that's half the population of the planet!

If you provide

  • table description in form of create statement
  • sample data in form of insert statement
  • your current query
  • expected output (from the sample data you provide)

you are more likely to get answers. most people won't bother to answer if they have to, all, individually, in duplicate, do that work as well as answering your question - or they will provide an untested answer which tends to lead to bugs and further questions which ... again ... takes up valuable contributor's time