|
SQL SERVER TRIGGERS[^]
________________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
The inserted table is a SQL Server in-memory structure only available within triggers fired during INSERT and UPDATE operations. The table has the same structure (columns) as the table that the trigger is defined on and contains as many rows as have been inserted or updated. The inserted table contains the values that are being inserted into the base table.
For example, you have Table1 with 2 columns; [col1] and [col2] and you have defined an insert trigger on Table1. When you try to insert a row into Table1 containing the values "A" for col1 and "B" for col2, the trigger fires. Within the context of the trigger, SQL Server provides you with a temporary in-memory structure called 'inserted' which contains 2 columns; col1 and col2 and this table has 1 row containing the values "A" and "B" respectively. You can query this table just like any other table using available T-SQL constructs e.g SELECT , JOIN , UNION etc.
So to put the new data into another table, just query the 'inserted' table and insert the results wherever you want.
Just for the sake of completion, SQL Server also offers you another table called 'deleted' available in triggers fired for DELETE and UPDATE operations. It can be used in the same manner as the 'inserted' table only that it contains the values that are being deleted/modified from the base table.
Nathan H. Omukwenyi
|
|
|
|
|
iam getting error when setting the value to the variable.
|
|
|
|
|
can you post what you have written along with the error message ?
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
ok i got the solution.i forgot to keep it in single quotes.
|
|
|
|
|
Ravi Shankar43 wrote: iam getting error when setting the value to the variable
Hi,
Suppose you have a varchar type variable, named @abc . With T-SQL you can assign value to @abc in two ways.
1- With the SET keyword
SET @abc='Its varchar typed'
2- With the SELECT keyword
SELECT @abc='Its new value'
However, with the SELECT keyword you can assingn values to multiple variables according to the following syntax.
SELECT varialbe1 = value[, variable2 = value, ...]
________________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
I want to display 10th record to 20th record from a table. I have no any field to store the recordno. I am using sql Server2000.
Bharat Bhusanam
|
|
|
|
|
Hi,
If you have some ID field, you can do something like this ---
If you have emp table like this --
Emp_Id Emp_Name Emp_Salary
1 ABC 2500.0000
2 ACD 1000.0000
3 AND 6000.0000
4 SVN 10000.0000
5 AYK 8500.0500
6 AT 8500.0000
7 NM 8500.0000
8 AK 5000.0000
9 VD 20000.0000
10 VP 100.0000
11 CV 8500.0000
then you can do something like this--
SELECT *
FROM (SELECT TOP 3 *
FROM (SELECT TOP 5 *
FROM EMP
ORDER BY EMP_ID ASC) AS T10
ORDER BY EMP_ID DESC) AS T5
ORDER BY EMP_ID ASC
this will return records from 3 to 5
you can change values dynamically (from program) to get desired results
hope i am clear !
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
|
iam selecting the date from calender control into the textbox.when iam inserting into database(sql2ooo) it is showing the time also.i dont want to display time in the frontend(datagrid).what should i do?
ravi shankar
|
|
|
|
|
hi,
use something like this
select convert(varchar,getdate(),101)
you can use your column name instead of getdate()
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
|
I wnat to know how to access the sql server 2000 errors in vb.net.
Also how to handle these errors in the client place.where to save them.
|
|
|
|
|
hi,
i think for each error that is fired from sql server you get exceptions in .net? You can handle them there.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hi,
Is there anyway to append query result rows together in SQL? For example, i want to append/concatenate all rows with same id.
Table:
id column1 column2 column3
1 a b c
1 d e f
2 g h i
2 k l m
Result:
id column1 column2 column3 column4 column5 column6
1 a b c d e f
2 g h i k l m
I'll appreciate any help.
Thanks
|
|
|
|
|
Are you wanting to update the table to have "6" columns with a value in each, do you want to just view the "results" in 6 columns or do you want 1 column with all values "appended" together?
|
|
|
|
|
Thank you for your response. I want to view the result in 6 columns.
|
|
|
|
|
Hope this is the right forum. If not, please feel free to direct me elsewhere...
I'm trying to build a suite of reports using Reporting Services 2005. At the most general level, there will be a report of Year-to-date sales data - pretty standard stuff; revenue, expense, net revenue, revenue per unit, etc. comparing current to previous year. The national totals will be at the top of the report. Beneath that will be the same data for each of 6 Sales regions. I have made the name of each region click-through to a similar report for that region. On the regional report, the top line is the regional totals, with the same info for each sales rep beneath it.
I'm simplifying a bit to keep the example simple. There are additional details included in groups on each of the reports which make combining them into a single report impractical.
Given the amount of calculations involved, and the fact that the data will only be updated monthly, this is a classic case where snapshots would help me display the pages more quickly.
I've got the national report running on a snapshot. The problem is with the regional report; since the click-through passes that report a parameter, I am trying to get the snapshot to run for each region. If I enter a single parameter in Properties -> Parameters, it only runs the snapshot for that region. I tried making it a multi-value parameter, but then clicking on the region name always brings me to the data for the region that is listed first, regardless of which region was clicked.
I'm hoping that there is a way that I can get the snapshots to run for each region, so the regional report will display in a timely fashion.
Thanks.
|
|
|
|
|
How can i get the phonenumbers starting with 98494 series from the database?Plz i need a query for this.
|
|
|
|
|
Select phonenumbers from PhoneBook Where phonenumbers LIKE '98494%'
sameer
|
|
|
|
|
|
Hi,
I am trying to set a property for the connection string: Auto Translate.
As I am using SQLconnection object rather than OLE or ODBC, is there any way for me to turn off the Auto Translate option? Otherwise, I would get all the crazy characters for my Big5 Chinese words from Database. This problem was solved by setting that auto translation off for ODBC when i was still using asp when we first developed the application. Due to the performance issue, we switched to SQLconnection rather than ODBC.. is there any way to come around for this problem?
Given condition: SQL Server 2000 and database structures cannot be changed.
I am very new to .net and your help will be very appreicated! Thanx!!
|
|
|
|
|
This one is driving me mad - hope someone can help.
I have a VB.Net app in VS2005 and I wanted to bind it to a SQL Server 2005 table so I dragged a DataGridView control onto a form and defined the datasource to come from the table I want to use and VS2005 went ahead and generated the XSD and the screeds of code which is great.
I then refined my table (using SQL Server Studio, not VS2005), adding a new column and changing a couple of column types in the DB table but I can't see ANY way to get VS2005 to get the updated table except to trash the generated Dataset, BindingSource and TableAdapter objects and do the whole binding exercise all over again! I've tried right-clicking and doing a refesh wherever I can that option but it never updates the code behind or the XSD. Now, I seem to remember in VS2003 there was a "Regenerate" command (or something like that) so where the heck is the equivalent in VS2005? Right-clicking on the XSD file in solution explorer has an option "Run custom tool" which I think runs "MSDataSetGenerator" but it doesn't seem to refresh or regenerate anything!
I've searched high and low and looked everywhere but I can't see any way to keep the VS2005 table concurrent with the underlying DB table - surely with the integration of SQL Server and .Net 2.0 I'm not expecting the impossible?
Can someone help me out here and tell me what I'm missing?
TIA...
Mike
-- modified at 18:00 Saturday 4th November, 2006
|
|
|
|
|
Hi
How can i get column names of a given table from a MS Access DB? Is there any query to do it?? Please help.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Look at the answers to your previous post.[^]
Chandra
|
|
|
|