You are here: Re: how to write one stored procedure for a (same column )present in 20 tables « MsSQL Server « IT news, forums, messages
Re: how to write one stored procedure for a (same column )present in 20 tables

Posted by MC on 03/08/06 13:34

Do you mean calling the procedure for any one table and then getting the
data from the table with a date filter? If yes, then you would need to use
dynamic string and send the table name and two dates to the stored procedure
as parameters. Something like

create procedure dbo.GetData
(
@tablename varchar(100),
@dateFrom datetime,
@dateTo datetime
)

as

execute
('
select * from '+@tablename +' where date >= ' + @dateFrom +' and date <= '+
@dateTo
)

go

offcourse, you should check the part with dates and see what would you
actually want to get back. Do you want to filter by time, should it include
or exclude datefrom data in the results and so on. You should also consider
using sp_executesql instead of execute.



MC



"satish" <satishkumar.gourabathina@gmail.com> wrote in message
news:1141816401.668563.36960@z34g2000cwc.googlegroups.com...
> hi,
> i am a learner of ms -sql server 2000, i had a doubt in stored
> procedures
>
> suppose i have a data base having 20 tables, all the tables have a
> column named--DATE
>
> can we write a store procdure to find out the data ---i mean i want
> the data entered
> between two days ---- if i call the stored procedure in any one of the
> table i need to get the answer
>
> pls help me how to write the stored procedure
>
> satishkumar.g
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация