|
i got 2 tables Reports_tbl and Manger_tbl
Reports_tbl
Manager DepID NumOfEmp_Reports
1 1 2
1 2 5
1 3 1
2 1 13
2 2 10
2 3 0
3 1 1
3 2 2
3 3 9
Manager_tbl
ManagerID ManagerName
1 Sam
2 Joseph
3 Paul
assuming that DeptID as Fin =1, Mng =2 and Sec =3 because i have to show Name of departments and NumOfEmp_Reports to sam,joeph,and paul
i have written query
select m.ManagerName, r.NumOfEmp_Reports as Fin ,r.NumOfEmp_Reports as Mng ,r.NumOfEmp_Reports as Sec
from Manager_tbl as m
Inner join Rerports_tbl as r
on m.managerId =r.mangaerId
the result of this query is as
ManagerName Fin Mng Sec
Sam 2 2 2
Sam 5 5 5
sam 1 1 1
Joseph 13 13 13
Joseph 10 10 10
Joseph 0 0 0
Paul 1 1 1
Paul 2 2 2
Paul 9 9 9
but i have to diplay result as following
ManagerName Fin Mng Sec
Sam 2 5 1
Joseph 13 10 0
Paul 1 2 9
thnx in adv for any kind help.
regards learner
|
|
|
|
|
If I interpreted yhe question correctly, you could use PIVOT[^]
|
|
|
|
|
thanks for your kind help.
|
|
|
|
|
|
Hi,
My stored procedure returning XML data (I am using FOR XML Auto ) . I want to save the same as XML File from that procedure itself . I am using SQL Server 2005 .
Any Idea to implement
Thanks in advance !
|
|
|
|
|
I have used bcp and execute it by xp_cmdshell
|
|
|
|
|
Just as an alternative because xp_cmdshell has some security issues, I think you could create a linked server against ODBC DSN and use ODBC Text Driver. Using that, you could write to the linked server as it was a table.
|
|
|
|
|
Hi,
I have to query the table,which have more than 3 or 4 level of hierarchy.
I need to get all the leaf nodes of particular Parent.i tried Querying like this-select * from Hierarchy where UniqId not in (select Parent from Hierarchy).but it returns leaf nodes of all the parent.what i need is to get leaf nodes of particular Parent.
can anybbody please help me to solve this issue,its realy very important.
Thanks and regards
Vidhya
|
|
|
|
|
can you please let me know the table structure?
|
|
|
|
|
|
Hi all,
I have written an insert query in a Stored Proc,
It works fine and inserts an record in the table, but
it returns -1 when i execute it thru C# Code.
Can anyone tell me why this happens?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
first paste your stored procedure code here.
do you return any thing in your procedure code?
|
|
|
|
|
i dont return any thing from the proc, but the default value returned from an insert proc is 1,
in my case donno y it returns -1.
I have done some calculations into some variables and a simple insert statement is used to
insert the record in the table,
I have also used a transaction for this and
after the insert statment i have checked if the @intErrorCode is not 0 then rollback transaction,
The insert works fine but it returns -1.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
if you call another stored procedure for insert into this procedure?
if this is true:
call to another procedures into one procedure cause returning -1
|
|
|
|
|
Which function you are using
ExecuteScaler, executenonquery, etc
Please specify
|
|
|
|
|
dbcommand.ExecuteNonQuery();
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Do you mean ExecuteNonQuery returns -1? If yes, see what the documentation says
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers. For all other types of statements, the return value is -1. If a rollback occurs, the return value is also -1.
|
|
|
|
|
yes, tht's a problem, i can the values in the table that means the insert statement was executed, and if an error has occured the insert should be rolledback rite, but this rollback is not happening and m not able to find what the error is.
wht r the ways to find the error that has caused the rollback?
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
In your stored procedure you can use RAISERROR[^] to generate an error and to inform client what has happened.
|
|
|
|
|
Since you are using Stored procedures, you can handle the errors inside the procedure and rollback if necessary. Add an output parameter which can be used to inform the client program about the process status. Something like,
CREATE PROCEDURE Foo
@FooColumn int = NULL
@ProcessStatus varchar(100) = NULL
AS
IF @@ERROR <>0
BEGIN
ROLLBACK
SET @ProcessStatus = 'Rollbacked'
END
ELSE
BEGIN
SET @ProcessStatus = 'Completed'
END
|
|
|
|
|
Thanks guys for all you suggestions,
I found the problem with my stored proc,
I had written SET NOCOUNT ON;
which was causing the -1 to return.
Now i have switched oFF that and it returns me 1.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
Hi experts
I've created a database ( named database1.sdf )
Then , I've created two tables in it. ( date[^] & text[^] )
Now I'm going to create a relation between them with VS2008 SP1.
But this error[^] has occurred
What's wrong with it ?
How can I resolve it ?
Thank you in advance
|
|
|
|
|
Most likely you have a mismatch in the code behind of xsd itself. Click DateID column in your dataset designer and check the DataType property from properties window.
|
|
|
|
|
Wow, thanks
|
|
|
|
|
You're welcome
|
|
|
|