|
Dear John,
I'm sorry that my question confuse you. Actually, I just need the result with the Column names that has maximum values.
Let me try to be clear.
Here is the result of my query.
Department City1 City2 City3 City4 City5 City6
Operations 4 2 6 NULL 1 NULL
Risk Management 4 5 1 NULL 2 NULL
Technology 2 3 5 NULL 1 NULL
I want to remove the column with NULL values.
That's exactly what I want.
Thanks ,
RB
|
|
|
|
|
I think I know what you want
<br />
SELECT * from TABLE<br />
ORDER BY City DESC<br />
ORDER BY WITH SUM
<br />
SELECT *, SUM(City1 + City2 + City3 + City4 + City5 + City6) as Total<br />
from TABLE<br />
ORDER BY Total DESC<br />
|
|
|
|
|
Hi,
How can i list the queues of the Service Broker and clear them?
thank you a lot.
|
|
|
|
|
i faced problem during reading xml file by sql function, xml file is comm separeated.
The Stifler
--
Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.
|
|
|
|
|
I can imagine you have a problem with a xml-file when it is comma seperated.
Wout Louwers
|
|
|
|
|
how t o call a stored procedure inside a stored procedure
|
|
|
|
|
|
I want stored procedure A to call stored procedure B, which returns a set of records from a table. Then, I want stored procedure A to perform work on these records. How do I call stored procedure B from within stored procedure A?
|
|
|
|
|
didn't you try the link???
ok try this... this sample has a parent stored proc that calls a child stored proc by passing parameter values and then does some insert operation...
Google the Google...[^]
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
yeah i got that one john,
one more thing is...
i have one field in my table which i want to update after inserting some values in the table.
i have written one stored procedure for inserting values,
i want to update one field depending upon the inserting values.
can u help me...
|
|
|
|
|
you can do both Insert and Update in single procedure. I'm not sure about why you want to do in 2 procs...ok... you can go through the below sample.
CREATE PROCEDURE sp_Update
(
@col1 varchar(20)
@ValuePassed varchar(50),
)
AS
declare @Id int
EXEC sp_Insert @ValuePassed, @Id OUTPUT
Update SomeTable
(col1, col2)
VALUES
(@col1, @Id)
RETURN
GO
CREATE PROCEDURE sp_Insert
(
@ValuePassedIn varchar(50),
@Id smallint OUTPUT
)
AS
INSERT INTO LookUpTable(column1)
VALUES(@ValuePassedIn)
SET @Id = Scope_Identity()
END
GO
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
The thing is,
i have one one registration page.
in that if user chooses his own question for security(while signup in yahoo also we will get security question like that) then the table field must b updated and question flag should be "yes"
if i take the custom question option else not.
how we will make that?
|
|
|
|
|
bhattiprolu wrote: i have one one registration page.
in that if user chooses his own question for security(while signup in yahoo also we will get security question like that) then the table field must b updated and question flag should be "yes"
if i take the custom question option else not.
with this information it's quite difficult for me to assume the table structure, their relationships and giving you a stored procedure in working condition.
In the previous post there is a sample procedure. I guess if you understand that you can solve your problem. First do an insert in whichever table you want and then read the newly inserted records PK_ID value using SCOPE_IDENTITY(). with primary key value of the newly inserted record you can perform the subsequent update in whichever table you want...
Hope this helps....
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hi ! I am writting a Dictionary online website. I want to insert,update,delete data from gridview but I have some trouble.so I want to ask how to do that ? Thanks so much !
|
|
|
|
|
Tuanhung189 wrote: I have some trouble.so I want to ask how to do that ?
How to do what???????? You mean how to write stored proc to insert, update and delete...
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
you can take the celles from grid view after that you can set data in
sqlcommand.commandtext="insert into tablename(col1,col2,col3)values(cell1,cell2,cell3)"
|
|
|
|
|
Hi. I'm hosting on a SQL server 2005 some encrypted data which could be stored as binary (Hex) or base64 (varchar).
What datatype would be best to use varbinary for the hex or varchar for the base64?
Is there any difference between them in memory usage?
|
|
|
|
|
never.reply wrote: What datatype would be best to use varbinary for the hex or varchar for the base64?
byte arrays and strings respectively
never.reply wrote: Is there any difference between them in memory usage?
Yes. Base 64 encodes things as characters, and as the name suggests this is in base 64 which is represented by only 6 bits. So base 64 will take more memory to store.
|
|
|
|
|
|
It's all right - I'll 5 vote Colin for you. Sheesh, come on guys - he's helping you; show some appreciation.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Can you please tell me how to delete a perticular row from a table in SQL Server 2005?
|
|
|
|
|
delete from tablename where id in(1,4,6)
this sql query deletes row 1,4 and 6
I Love SQL
|
|
|
|
|
Suresh R.. wrote: how to delete a perticular row from a table in SQL Server 2005
you can have this...
--Deleting single or multiple rows
DELETE FROM TABLE WHERE ID = VALUE
DELETE FROM TABLE WHERE ID IN (VALUE1, VALUE2, VALUE3)
--deleting top 100 rows
DELETE FROM TABLE WHERE ID (SELECT TOP 100 ID FROM TABLE ORDER BY ID)
--delete records in one table based on values in another table
DELETE FROM TABLE A
WHERE EXISTS
( SELECT ID
FROM TABLE B
where B.ID = A.ID)
--delete records in one table based on values that doesn't match in another table
DELETE FROM TABLE A
WHERE NOT EXISTS
( SELECT ID
FROM TABLE B
where B.ID = A.ID)
--deletes all rows and reinitializes the table
TRUNCATE TABLE TABLENAME --(not reccommended if you
--don't know the exact use of truncate stmt)
--deleting duplicate rows from a table
Check This[^]
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hi!
I have a project to talk about "Concurrency Control" in SQL Server. Please! give me some imformation (or ebooks)talking about "Concurrency Control".
Thanks!
|
|
|
|
|