Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Truncate and rebuild a table
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01629214
Message ID:
01629221
Vues:
29
>>>>>>Hi,
>>>>>>
>>>>>>Is it unconventional or maybe "harmful" to a SQL Server if I have a procedure that truncates a table and than inserts new records into this table (basically rebuilds it). The table itself (which stores some calculated values) is on average about 50 records/rows and it has about 60 columns. This procedure, "truncating and re-inserting" would happen about 1000 times a year. At most I see it occurring 10,000 times a year.
>>>>>>
>>>>>>What do you think?
>>>>>
>>>>>Why you need this?
>>>>>1. Create SP that will return calculated records.
>>>>>2. Create Table valued function.
>>>>>3. Create View
>>>>
>>>>I think the above three cases are the three alternatives, right? If so.
>>>>1. I have not thought about this. But given that SQL Server is very fast this could be a viable alternative. I will explore this.
>>>>2. I am not familiar with this feature
>>>>3. I am not familiar with this feature.
>>>>
>>>>But I will explore the 1st approach.
>>>>
>>>>Thank you.
>>>
>>>
>>>Table valued functions are like normal functions but they return table.
>>>The best of Table valued functions is that you can use them in query like regular table.
>>>Something like that:
>>>
>>>SELECT * FROM MyTable
>>>INNER JOIN dbo.SomeTableFunction(parameter1, ..., parameterN) Tbl ON ...
>>>
>>>
>>>or even:
>>>
>>>SELECT * FROM dbo.SomeTableFunction(parameter1, ..., parameterN) Tbl
>>>INNER JOIN  SomeTable ON ...
>>>
>>
>>Thank you very much for the examples.
>
>Here one very good explanation for Table Valued functions:
>http://www.codeproject.com/Articles/167399/Using-Table-Valued-Functions-in-SQL-Server
>If you google "table valued function sql server" you will see many good examples :-)

Thank you very much. Even though I understand (a little) now about Table Valued functions, but it seems to me that your first approach, stored procedure that returns values, maybe the fastest. For me, in this particular case, the speed of getting the values/data into VFP app is very important.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform