Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to find rows with triggers

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2011-12-17 : 15:37:39
Imam Tabela 1 in table2

struktura:
Tabela 1
Id, Type, Višina
12, 4, 10
13, 4, 25
14, 4, 49


Ce i shranjeni v Type Tabela 1 = 4, je treba s prožilcem najti vrstici 1 in 3 v Tabela 1 in shraniti:

table2
id, Znesek
1, 10
2, 49

Torej, je treba najti vrstic 1 in 3. Iskanje preko id (12, 14) je izkljucena. Moram najti vrstice, 1,2,3 ....
Kako najti vrstice z sproži?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-17 : 15:58:34
Could you please translate to English? Only one that I know of that speaks Slovenian here is Mladen, not sure here's going to see this thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-12-17 : 16:01:17
quote:
Originally posted by tkizer

Could you please translate to English? Only one that I know of that speaks Slovenian here is Mladen, not sure here's going to see this thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



Sorry,

I have a table 1 and table2

structure:
Table 1
Id, Type, Amount
12, 4, 10
13, 4, 25
14, 4, 49


If i stored in Table 1 Type = 4, it is necessary to find a trigger rows 1 and 3 in Table 1 and to save:

table2
id, amount
1, 10
2, 49

So, it is necessary to find rows 1 and 3 search by id (12, 14) is excluded. I need to find rows 1,2,3 ....
How to find row with trigger?
Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2011-12-17 : 16:16:21
quote:
Originally posted by programer

quote:
Originally posted by tkizer

Could you please translate to English? Only one that I know of that speaks Slovenian here is Mladen, not sure here's going to see this thread.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



Sorry,

I have a table 1 and table2

structure:
Table 1
Id, Type, Amount
12, 4, 10
13, 4, 25
14, 4, 49


If i stored in Table 1 Type = 4, it is necessary to find a trigger rows 1 and 3 in Table 1 and to save:

table2
id, amount
1, 10
2, 49

So, it is necessary to find rows 1 and 3 search by id (12, 14) is excluded. I need to find rows 1,2,3 ....
How to find row with trigger?



I tried like this:
select Row_Number() Over (Order by ID) As Row from table1


INSERT INTO table2 (Odds) VALUES (select Row from table1);

I want to find in the table1 first and second row and then
to save in the table2 data from table1.

If I have in the table1
Id, Amount
50 10
60 25
70 49

Row=1 and Row=3.... in the second table to save 10 and 49.

How to do this?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-18 : 00:33:45
whats the significance of 1 and 3 positions? and your explanation says I want to find in the table1 first and second row

anyways here you go with first and third rows. if you want first and second change rn values accordingly

INSERT INTO table2 (id, amount)
SELECT id, amount
FROM
(
SELECT ROW_NUMBER() OVER (PARTITION BY Type ORDER BY id ASC) AS Rn,id, amount
FROM table1
)t
WHERE Rn IN (1,3)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -