Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. pandatime

    Question about indexing

    Hi, I am wondering is it worthwhile to index a column in a table with 500 million rows if the column on only has 5 distinct values (and nulls) in it? The column is a varchar(255), but the longest value is about 10 chars long. Thanks
  2. pandatime

    SQL Server 2008 - problem with transaction

    Hi, This is what I am doing. Basically I want all inserts and deletes to run, or not at all. CREATE PROC myProc AS BEGIN BEGIN TRAN BEGIN TRY insert to table x... insert to table y... insert to table z... delete table a... END TRY BEGIN CATCH do something... END CATCH IF @@TRANCOUNT >...
  3. pandatime

    Converting week number to actual date

    SET DATEFIRST 1 declare @wk int set @wk = 1 declare @yr int set @yr = 2007 select dateadd (week, @wk, dateadd (year, @yr-1900, 0)) - 4 - datepart(dw, dateadd (week, @wk, dateadd (year, @yr-1900, 0)) - 4) + 1 -- was enough for me to figure out what I need, thanks!!!
  4. pandatime

    Converting week number to actual date

    Hi George, No, what I want is to sum up some data by week, so I'm selecting the week number then grouping on it. It works fine, but I also want to see what the actual DATE is for the given week number. So in my report it will look like: week_no date count 1 1/3/11 99 2...
  5. pandatime

    Converting week number to actual date

    1/3/2011 since that is the Sunday, and beginning of the week
  6. pandatime

    Converting week number to actual date

    I'm sorry that won't work because I don't want to group on created_dt, only week_no and the week day for that week_no as in 1 Jan 3, 2011 2 Jan 10, 2011 3 Jan 17, 2011 etc
  7. pandatime

    Converting week number to actual date

    Hi, I've been searching all over the internet but not coming up with a satisfactory answer. Basically, I have this query: select datepart(week, created_dt) as week_no from myTable which gives me: 1, 2, 3, etc for "week_no" but since this is for a report, I also want the ACTUAL date the...
  8. pandatime

    Need help with pivot expression

    Yes, this works, thanks. Unfortunately, I didn't really explain clearly what I wanted, sorry: REPORT: abc 2010-12-01 NULL NULL 2010-12-04 NULL def 2010-12-01 NULL NULL NULL NULL xyz NULL 2010-12-02 NULL NULL 2010-12-05 I need a column for each DAY...
  9. pandatime

    Need help with pivot expression

    Hi, I am not too familiar with the pivot expression and I can't seem to find any examples online. What I'm trying to do shouldn't be hard, just don't know the syntax. I am trying to achieve the output under "REPORT". RAW DATA: name date abc 2010-12-01 abc 2010-12-04 def...
  10. pandatime

    Help writing this query

    @gmmastros: Yes that works great - thanks so much
  11. pandatime

    Help writing this query

    Correction, the query should be: select id, sku from myTable into #temp where sku = 'abc' or sku = 'def' or sku = 'ghi' or sku in ('yy', 'zz') group by id, sku order by id, sku
  12. pandatime

    Help writing this query

    Yes, it's possible to duplicate the data. That's why I'm grouping on id and sku. Thanks
  13. pandatime

    Help writing this query

    Yes, on both points. Thank you
  14. pandatime

    Help writing this query

    Hi, I have a query that I know is probably easy to write, but I'm just missing it for some reason. Here's the basic query: select id, sku from myTable into #temp where sku = 'abc' or sku = 'def' or sku = 'ghi' or sku in ('yy', 'zz') group by profile_id, sku order by profile_id, sku Basically...
  15. pandatime

    parsing a comma-delimited string in column?

    Hi, I have a table with a column that can hold single values as well as a comma-delimited string, for exampe: column Joe, 1, Red Mary Ned, 2, Blue, Purple Susan, 3 etc How can I write something to grab a distinct result set of all the various values, which would be: Joe Mary Ned Susan 1 2 3...
  16. pandatime

    Best way to write this query?

    Hi, My data set looks like: id type date count 1 dogs 2010-01-01 1 1 dogs 2010-01-15 4 1 dogs 2010-01-31 10 1 cats 2010-02-02 4 1 cats 2010-02-16 7 What I want to do is write a query that will return the record that contains the max(date) for a given...
  17. pandatime

    Can only sysadmin check job history?

    I figured there might be a role, didn't realize it was at db level... Thanks
  18. pandatime

    Can only sysadmin check job history?

    Hi, is there a way to let someone check job history but not as sysadmin? Thanks
  19. pandatime

    need help with simple, yet complex query

    Hi, Nevermind, I figured it out. Turns out if I put the results for both tables in a temp table first, it is a relatively easy matter to get what I want by the use of a correlated subquery using min. I guess I got myself confused by overcomplicating the issue, and not taking a sufficient break...
  20. pandatime

    need help with simple, yet complex query

    Hi, Starting completely over from scratch, here's some sample data: TableA (i.e. available) group id title level GROUP1 1000 BLUE 1 GROUP1 1002 BLUER 2 GROUP1 1003 BLUEST 3 NULL 1004 CATS NULL NULL 1005 DOGS NULL NULL 1006 MONKEYS...

Part and Inventory Search

Back
Top