Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my table FinancialYearMaster contains finyearID and FinYear.in my asp design part, i want filled values to a dropdownlist.It contains one more financial years like(12/11/2012).
i want to select a value from a dropdownlist through sql server stored procedure.Logically the function behind the selected value is that check the the selected value is equal to current fin year is true like(11/1/2012=1/3/2012) else if the value is less than current finyear select above value of current year that is 12/2/2012-1=12/2/2011.
Posted
Updated 4-Mar-13 20:35pm
v3
Comments
Azziet 5-Mar-13 1:16am    
question is not clear?? you want it c# or sql...
renjimaramanan mr 5-Mar-13 1:19am    
i want to write a stored procedure
renjimaramanan mr 5-Mar-13 1:21am    
i want in sql server
Zoltán Zörgő 5-Mar-13 2:25am    
But you speak ok dropdownlists. There is no dropdownlost on sql level. We can not figure out what you want this stored procedure to do. Please reformulate your question and remove all irrelevant parts of the question.
Shanalal Kasim 5-Mar-13 4:06am    
question is not clear?

Try something like that:
SQL
CREATE PROCEDURE GetFinYear()
    @aYear INT
AS
BEGIN
    DECLARE @cYear INT
    
    SET @cYear = YEAR(GETDATE())
    
    IF (@aYear<@cYear)
    BEGIN
        SELECT *
        FROM YourTable
        WHERE YEAR([FinYear]) = @aYear
    END
    ELSE
    BEGIN
        SELECT *
        FROM YourTable
        WHERE YEAR([FinYear]) = @cYear
    END

END
 
Share this answer
 
Comments
RedDk 5-Mar-13 12:14pm    
Definitely better than piracy. Use this.
RM,

Here's what I did the first time I decided I wanted to create my own SP. I'll give you a step-by-step. I'm using ssmse2k8 but there are other versions so the "Object Explorer" might be different.
1. Make sure a database you want to add a stoproc to has it's "System Stored Procedures" folder visible in the treeview of Object Explorer window. 
2. Open that folder by clicking on the "+" abaft of the folder icon.
3. You should see a bunch of "sys.sp_(etc...)" procedures listed now.
4. Scroll down to "sys.sp_rename" and right-click on the icon then select "modify".
5. Before you  do anything else, after that "sp" opens in the Editor window, stick your cursor at the eighth line and change the word "ALTER" to "CREATE".
6. Save that .sql "script" to "sp_rm_rename".
7. Move your cursor to the right 12 spaces and change "[sys]" to "[dbo]" and substitute "[sp_rename]" using "[sp_rm_rename]".
8. Now hit F5 to run this new script of yours.

You should now have your first custom stored procedure. You'll find it in the treeview, more easily after you close that "System Stored Procedures" folder you just opened, in the list of "Stored Procedures" under the SCHEMA "[dbo]".

Now you can edit any one of those variables you just "billteached" off the deck of systemSSMSE.

Marvelous ain't it?
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900