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 dencom 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: *

  • Users: pandatime
  • Content: Threads
  • Order by date
  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

    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...
  4. 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...
  5. 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...
  6. 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...
  7. 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...
  8. pandatime

    Can only sysadmin check job history?

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

    need help with simple, yet complex query

    Ok, let's see if I can explain this. The query below returns the result set below: select a.group, a.id, a.title, c.completed_dt, c.viewed_dt from myTableA a left join myTableC c on (a.id = c.id) and c.id = 123 order by c.completed_dt desc, newid() -- randomizes Sorry about the formatting...
  10. pandatime

    need help with query using join and count

    Hi, I am having problems getting the right count(*) when I join two tables. See code below: insert into #temp (id, code, frequency) select f.id, d.code, count(*) from TableF f join TableD d on (f.id = d.id) group by f.id, d.code order by code What I get for count(*) is the "product" of the...
  11. pandatime

    need help with sql syntax (self join)

    Hi, I would like to return a result set like so: widget count(where clr = red) count(where clr = blue) 123 5 11 124 0 3 125 17 21 etc... The table has a "widget" column...
  12. pandatime

    Need help with BCP syntax

    Hi, I am having issues trying to get this to work. I can't really see what the problem with my syntax is: declare @execMe varchar(255) declare @fileDt varchar(20), @fileName varchar(40) select @fileDt = convert(varchar, GetDate(), 120) set @fileDt =...
  13. pandatime

    Question about filegroup usage

    Hi, This question came up for me today, and now I'm not sure what the answer is. Let's say you create a table in a database comprised of multiple filegroups. By default it will use the "primary" filegroup. But let's further assume that the "primary" filegroup is mostly or totally full. So...
  14. pandatime

    job problem

    Hi, I am seeing something very strange. After some issues with the server last week (a shutdown of a database after the templog got too big and couldn't grow due to a size restriction), the sql server agent wouldn't start properly. We solved the problem by rebooting the server and everything...
  15. pandatime

    help with dupe query

    Hi, I have a query I'm using to eliminate duplicate rows from a table with about 5 mil rows. PK is a clustered index. The problem is, it's extremely slow. When I look at the execution plan, it's very complex, and I see most of the cost is on "sort". Is there a way to do this that is more...
  16. pandatime

    Need query help

    Hi, I have situation where I need to check if rows do not exist across tables. The problem is, the columns I am checking to determine this contain data that is not unique across the tables. For example, myTable1 contains: pk id system_date 1 10 2010-01-01 1 10 2010-01-02 2 10...
  17. pandatime

    Proc keeps going even after error???

    Hi, A proc was running today, doing an insert to a table. At a certain point, the disk space filled up so the insert statement couldn't complete. SQL Server then issued an error to that effect (as shown in my job history), but the proc kept running (as evidenced by other actions that occurred...
  18. pandatime

    need help with bulk insert

    Hi, I have a flat file separated by pipes, sample below: The row numbers are NOT in the file. However, when I view "line numbers" in textpad, that's what it shows. There is an extra line "4", but no data on it. That's where my bulk import is failing: I am using a format file. How do I...
  19. pandatime

    BULK INSERT - can you use a space as field terminator???

    Hi, That's basically the question. I have a file that is delimited by spaces and tabs. The tabs is easy, char(9). But how do I specify in the format file that I want it break on a space? I tried: 9.0 6 1 SQLCHAR 0 255 "' '" 3 SYSTEM_DATE "" etc... but it doesn't like: The bulk load...
  20. pandatime

    BULK LOAD problem

    Hi, I am trying to load a file using bulk load. It's only loading EXACTLY one-half of the rows in the file! Exactly one-half to the letter. I'm looking at the data in the file, but there NO difference between the first half and the second half whatsover. What could be the problem? Here is my...

Part and Inventory Search

Back
Top