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.
Author |
Topic |
casati74
Posting Yak Master
109 Posts |
Posted - 2006-08-25 : 04:15:54
|
Hello, I must assign a cursore value to a varible, how can i do it????I haveDECLARE @nometabella nvarchar(100)DECLARE miocursore CURSOR FORSELECT valore FROM #miatmpOPEN miocursore-- Perform the first fetch.FETCH NEXT FROM miocursore-- Check @@FETCH_STATUS to see if there are any more rows to fetch.WHILE @@FETCH_STATUS <>-1BEGINselect @nometabella = miocursore ***** This is a problemprint @nometabella FETCH NEXT FROM miocursoreENDCLOSE miocursoreDEALLOCATE miocursoreGOHow can i assigna to @nometabella a miocursore.value????Thank's |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-25 : 04:20:13
|
[code]DECLARE @nometabella nvarchar(100)DECLARE miocursore CURSOR FORSELECT valore FROM #miatmpOPEN miocursore-- Perform the first fetch.FETCH NEXT FROM miocursore INTO @NomeTabella-- Check @@FETCH_STATUS to see if there are any more rows to fetch.WHILE @@FETCH_STATUS <>-1BEGIN--select @nometabella = miocursore ***** This is a problemprint @nometabella FETCH NEXT FROM miocursore INTO @NomeTabellaENDCLOSE miocursoreDEALLOCATE miocursoreGO[/code]Also read about CURSORS in Books Online.Peter LarssonHelsingborg, Sweden |
 |
|
casati74
Posting Yak Master
109 Posts |
Posted - 2006-08-25 : 04:41:40
|
I have tried but making therefore forehead of every line me of it, it inserts 30 equal ones why? ex:SamplesSampleID 9822SamplesSampleID 9822SamplesSampleID 9822SamplesSampleID 9822SamplesSampleID 9822SamplesSampleID 9822SamplesSampleID 9822SamplesSampleID 9822SamplesSampleID 9822but if exec a select where id = 9822 i recive only one rowSamples 9822 I 2006-08-05 06:08:01.093 Why????Thank's a lot |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-25 : 04:43:55
|
I can't tell since I don't know the insert statement.Try to useDECLARE miocursore CURSOR FORSELECT DISTINCT valore FROM #miatmp orDECLARE miocursore CURSOR FORSELECT valore FROM #miatmp where id = 9822 Peter LarssonHelsingborg, Sweden |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-25 : 04:46:01
|
I think the data in temporary table #miatmp is the problem.writeselect * from #miatmp to see if the data is duplicated there.Peter LarssonHelsingborg, Sweden |
 |
|
casati74
Posting Yak Master
109 Posts |
Posted - 2006-08-25 : 04:47:01
|
thank's a lot a solv after send a new topic!!!!Thank's!!!! |
 |
|
|
|
|