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 2000 Forums
 Transact-SQL (2000)
 Parameter is equivilant to field name

Author  Topic 

JAdauto
Posting Yak Master

160 Posts

Posted - 2004-05-03 : 22:26:05
Somehow I posted this topic under the wrong forum. I think I was doing a search and selected new topic and it dropped it there. Anyway, this is my question if anyone has any suggestions.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=34780

JAdauto
Posting Yak Master

160 Posts

Posted - 2004-05-03 : 22:27:55
Actually, we just came up with this:

WHERE (ec.January = 1 and @MonthNumber = 1
OR ec.February = 1 and @monthNumber = 2
OR ec.March = 1 and @MonthNumber = 3
OR ec.April = 1 and @monthNumber = 4)

Is this the best solution?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-05-03 : 22:31:31
Looks reasonable - better would be to change the table and get rid of the named columns in favour of a bit map.
Or eve beter have another table linking to the records which have the month numbers for which they are applicable.
You could add this new table and populate it from your month fields without changing the structure of your current table.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -