dbTalk Databases Forums  

need a solution in sql server 2005

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss need a solution in sql server 2005 in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
rek
 
Posts: n/a

Default need a solution in sql server 2005 - 04-17-2010 , 10:16 AM






hi friends,
can any one help me pl!!
m using visual studio 2005 n ms sql server 2005 as backend.actually, i
have created a table with a column name as rid,total,cur_value and
balance.
In balance column, this total value minus(-) cur_value is stored.
1)now,after each transaction i wanna store this balance value into the
total column again automatically…how to do it?
2)how to increment the rid value lik (1,2,3,4,5…)after each
transaction is executed?
3) how to get a particular value in a table using aggregate function
as condition ?
4)is it possible to show error/alert msg if it exceeds the given
condition ?

thank you very much..

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: need a solution in sql server 2005 - 04-18-2010 , 04:34 PM






rek (pooh4rsoft (AT) gmail (DOT) com) writes:
Quote:
can any one help me pl!!
m using visual studio 2005 n ms sql server 2005 as backend.actually, i
have created a table with a column name as rid,total,cur_value and
balance.
In balance column, this total value minus(-) cur_value is stored.
1)now,after each transaction i wanna store this balance value into the
total column again automatically…how to do it?
I'm not sure that I understand the business rules. In a table with
a balance column, I would expect something for which we are keeping the
balance off, for instance an account. But I cannot see anything here.
Nor do I know what rid stands for. Or "total" for that matter.

OK, so given the meagreness of the column, this seems to be some form
of training exercise, but that may actually make things more difficult
as there is no clear definition of what you are aiming at.

Quote:
2)how to increment the rid value lik (1,2,3,4,5…)after each
transaction is executed?
Either you make the column an IDENTITY column, in which case SQL Server
would handle the increment, at the price that you will have to accept
gaps. Or something like:

DECLARE @rid int
BEGIN TRANSACTION

SELECT @rid = coalesce(MAX(rid), 0) + 1 FROM tbl WITH (UPDLOCK)

INSERT tbl (rid, ...)
VALUES (@rid, ...)

COMMIT TRANSACTION


Quote:
3) how to get a particular value in a table using aggregate function
as condition ?
Could you clarify what you are looking for?

Quote:
4)is it possible to show error/alert msg if it exceeds the given
condition ?
Again, could you clarify what you are looking for?

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.