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 2005 Forums
 Transact-SQL (2005)
 Create View or Table

Author  Topic 

stormcandi
Starting Member

46 Posts

Posted - 2007-09-18 : 17:25:15
Hello all,

I need some assistance on a project. I need to create a function (or something like it) that uses the current date to find out what school year we are in right now. I cannot use GetDate() or Current_Timestamp in a function and have done the research on the reason why. So I thought maybe I could create a temp view or table dynamically, use it, then delete it. I don't care about the time part of it, just the date so slight variations because of time are ok. I am just looking at the year portion of the date.

I cannot figure out if I should do a temp view and then delete it or a temp table then delete it. I also cannot figure out how to do this in a Stored Procedure. Does anyone know which way would be better and how to do this or if there is a better way to do it?

I am using 2005

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-18 : 17:54:15
I create a SYS_VARS or systems variable table which will hold excatly 1 row, with a trigger to make sure

For example, I need to know what "year" performace reviews are for. We have many years of data, but I only want the current one

Having this table allows me to join to it...and because it's one row, I don't have to worry about cartesian products.

Need som samples?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-18 : 17:55:55
It's kinda like a home grown set of global variables the app can use
\You can add as many columns as you want, and then dynamically change the "view" the application "sees"




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -