Viewing 15 posts - 61 through 75 (of 136 total)
Try this, using SQL2005.
create table #tmp (id int, oppcode int, partsamt int)
insert into #tmp values (1,891,100)
insert into #tmp values (2,971,50)
insert into #tmp values (3,null,75)
insert into #tmp values (4,654,500)
select * from...
March 20, 2006 at 5:38 pm
Oh, sorry - I misread what you wanted to group by.
The key here is just to create a query that gives you that value for 'Opp Code'. Bear with me...
March 20, 2006 at 5:32 pm
Does this work for you:
declare @tablename varchar(256)
set @tablename = 'Inventory'
-- First let's fetch the id column.
-- We could have done this in our cursor, but it's nice to separate...
March 20, 2006 at 4:18 pm
You're trying to write an update query without using column names?
You could generate the SQL you want into a string, and then execute that. It's not a nice way of...
March 20, 2006 at 4:09 pm
If you already have something that gives you 57 on records 1 through 4, then a normal sum query should do the job, right?
March 20, 2006 at 3:55 pm
As an exercise, it's fun to write the code to make a database do this kind of work. In reality though, you wouldn't use a database for it, because a...
June 27, 2005 at 7:08 pm
Noticed the large number of posts on this, and got curious.
Here's an iterative (non-recursive) search. It does it breadth-first, so it finds the solution that uses the smallest number...
June 26, 2005 at 3:13 am
Your WHERE clause means that you only get the rows in tableA that don't match something in tableB. Since you're being MORE RESTRICTIVE in finding matching rows in your second...
June 15, 2005 at 7:35 pm
This is one of those scenarios where I think I prefer the definite correctness. And for which I'm very glad about the 'row_number()' function in SQL2005.
June 9, 2005 at 6:21 pm
When I wrote: "To me it looks like a ranking function on the 'id' field", I was right, wasn't I?
It's basically...
select id, name, colid, row_number() over (partition by id order...
June 9, 2005 at 6:00 pm
Not everyone.
Very pleased that 2005 has user-defined aggregate functions (which reminds me, I need to play with that some more), so that people...
June 9, 2005 at 2:48 am
Oh, I know there's no guarantee... but that's the thing with this shortcut. Personally, I hate it and would rather use a CURSOR! But that's just because I prefer correctness...
June 9, 2005 at 2:21 am
But that's why he put the index on the table, so that it would order it for him without changing the 'order by', right?
June 9, 2005 at 2:05 am
Let me see... (please excuse the obvious bits)
-- Insert into Test (id, name, Colid) Select Distinct id, name, Colid from dbo.SysColumns
Well, [id] is the table name, so this just populates...
June 9, 2005 at 1:35 am
Well, you could put a foreign key on Chris' table, so that the system won't let you delete that row out of the original table until you've deleted it.
If you...
June 3, 2005 at 9:23 pm
Viewing 15 posts - 61 through 75 (of 136 total)