Showing posts with label employee. Show all posts
Showing posts with label employee. Show all posts

Friday, March 30, 2012

problem with chart and grouping

hy,

i have a problem with placing Percentages on a stacked bar chart. It displays the mount of days worked per employee.i group by year for catagory group and on a productive field for series grouping (vacation is a ligit booking but not productive)

to calculate the percent i have to do:
value grouped by productive and year/grouped by year

when i change the productive group to also group on year it displayed the bar in productive and not productive but the productive part had color and a line across the bar to point it out.

so i tried making 2 series groups, with the year groups output property set to no,and got the same result.

any help would be great.
Jensif my question isn't clear please say sosql

Wednesday, March 21, 2012

Problem with @@identity in SQL Server 6.5

In SQL Server 6.5, I have a table called employee
with two fields emp_id and emp_name where emp_id
is an identity column.

The below Stored Procedure is trying to select
the last inserted emp_id using @.@.identity.

CREATE PROCEDURE Employee AS

begin

SET IDENTITY_INSERT employee OFF

SET NOCOUNT ON

declare @.empid int

INSERT INTO employee(emp_name) VALUES
("Soundy")

SET @.empid = @.@.identity

return @.empid

end

But when compiling this procedure, SQL Server displays
an error saying "Incorrect syntax near @.empid".

Can i know where the problem is ?Q1 Can i know where the problem is ?

A1 Try 'Soundy' instead of "Soundy"? For example:

Use TempDB
Go

CREATE TABLE [employee] (
[emp_id] [int] IDENTITY (1, 1) NOT NULL ,
[emp_name] [nvarchar] (50) NULL)
Go

CREATE PROCEDURE ins_Employee
@.pEmpName nvarChar (50) AS
begin
SET IDENTITY_INSERT employee OFF
SET NOCOUNT ON
declare @.empid int
INSERT INTO employee(emp_name) VALUES
(@.pEmpName)
SET @.empid = @.@.identity
return @.empid
end

Go

DECLARE @.RC int
-- exec the Proc
EXEC @.RC = ins_Employee @.pEmpName = 'Soundy'
Select @.RC as '@.RC for ins_employee'
Go

SELECT emp_id, emp_name
FROM employee
Where
emp_id = (SELECT Max(emp_id)FROM employee)

Monday, February 20, 2012

Problem using a parameter in a subquery

The following code works (assuming that there is an employee with the alias
'some alias', of course)
ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.RowCount int output) AS SELECT
ExpenseLocations.LocationId, ExpenseLocations.LocationName
FROM ExpenseLocations INNER JOIN
myLocations ON ExpenseLocations.LocationId =
myLocations.LocationId
WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM
Employees WHERE EmployeeAlias = 'some alias'))
ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
However, the following parameterized code does not work:
ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.EmployeeAlias char, @.RowCount
int output) AS SELECT ExpenseLocations.LocationId,
ExpenseLocations.LocationName
FROM ExpenseLocations INNER JOIN
myLocations ON ExpenseLocations.LocationId =
myLocations.LocationId
WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM Employees
WHERE EmployeeAlias = @.EmployeeAlias))
ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
I am obviously doing something wrong but am not sophisticated enough
(apparently) to figure out why. Thanks in advance for any suggestions.
DuncanYou do not define a length of the char param
@.EmployeeAlias char
Should be something like this
@.EmployeeAlias char(10),
my suggestion:
exec sp_help Employees
make the variable the same length as the EmployeeAlias column as it is
defined within the table.
Keith
"duncans" <duncans@.discussions.microsoft.com> wrote in message
news:59D22412-47F6-4ED6-A1D9-B31C53994CC8@.microsoft.com...
> The following code works (assuming that there is an employee with the
alias
> 'some alias', of course)
> ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.RowCount int output) AS
SELECT
> ExpenseLocations.LocationId, ExpenseLocations.LocationName
> FROM ExpenseLocations INNER JOIN
> myLocations ON ExpenseLocations.LocationId =
> myLocations.LocationId
> WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM
> Employees WHERE EmployeeAlias = 'some alias'))
> ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
> However, the following parameterized code does not work:
> ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.EmployeeAlias char, @.RowCount
> int output) AS SELECT ExpenseLocations.LocationId,
> ExpenseLocations.LocationName
> FROM ExpenseLocations INNER JOIN
> myLocations ON ExpenseLocations.LocationId =
> myLocations.LocationId
> WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM
Employees
> WHERE EmployeeAlias = @.EmployeeAlias))
> ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
> I am obviously doing something wrong but am not sophisticated enough
> (apparently) to figure out why. Thanks in advance for any suggestions.
> Duncan
>

Problem using a parameter in a subquery

The following code works (assuming that there is an employee with the alias
'some alias', of course)
ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.RowCount int output) AS SELECT
ExpenseLocations.LocationId, ExpenseLocations.LocationName
FROM ExpenseLocations INNER JOIN
myLocations ON ExpenseLocations.LocationId =
myLocations.LocationId
WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM
Employees WHERE EmployeeAlias = 'some alias'))
ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
However, the following parameterized code does not work:
ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.EmployeeAlias char, @.RowCount
int output) AS SELECT ExpenseLocations.LocationId,
ExpenseLocations.LocationName
FROM ExpenseLocations INNER JOIN
myLocations ON ExpenseLocations.LocationId =
myLocations.LocationId
WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM Employees
WHERE EmployeeAlias = @.EmployeeAlias))
ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
I am obviously doing something wrong but am not sophisticated enough
(apparently) to figure out why. Thanks in advance for any suggestions.
Duncan
You do not define a length of the char param
@.EmployeeAlias char
Should be something like this
@.EmployeeAlias char(10),
my suggestion:
exec sp_help Employees
make the variable the same length as the EmployeeAlias column as it is
defined within the table.
Keith
"duncans" <duncans@.discussions.microsoft.com> wrote in message
news:59D22412-47F6-4ED6-A1D9-B31C53994CC8@.microsoft.com...
> The following code works (assuming that there is an employee with the
alias
> 'some alias', of course)
> ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.RowCount int output) AS
SELECT
> ExpenseLocations.LocationId, ExpenseLocations.LocationName
> FROM ExpenseLocations INNER JOIN
> myLocations ON ExpenseLocations.LocationId =
> myLocations.LocationId
> WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM
> Employees WHERE EmployeeAlias = 'some alias'))
> ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
> However, the following parameterized code does not work:
> ALTER PROCEDURE dbo.GetMyLocationsSubquery (@.EmployeeAlias char, @.RowCount
> int output) AS SELECT ExpenseLocations.LocationId,
> ExpenseLocations.LocationName
> FROM ExpenseLocations INNER JOIN
> myLocations ON ExpenseLocations.LocationId =
> myLocations.LocationId
> WHERE (myLocations.EmployeeId = (SELECT Employees.EmployeeId FROM
Employees
> WHERE EmployeeAlias = @.EmployeeAlias))
> ORDER BY ExpenseLocations.LocationName;SELECT @.RowCount=@.@.ROWCOUNT
> I am obviously doing something wrong but am not sophisticated enough
> (apparently) to figure out why. Thanks in advance for any suggestions.
> Duncan
>