all groups > sql server programming > october 2007 > threads for friday october 12
Filter by Day: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
divide Rows into groups of n rows and find the max
Posted by aquagal at 10/12/2007 6:04:00 PM
Hi All,
I am using SQL server 2000.
I need to do the following.
Suppose I have a table that has daily data called DailyTable
DailyTable
--------------
Day Value
--------------
1 10
2 60
3 25
4 46
5 67
6 81
7 12
8 45
9 24
10 87
11 100
12 ... more >>
Trigger to update a value when a certian value is entered into the database
Posted by Lord Kelvan at 10/12/2007 5:09:10 PM
ok i cannot for the life of me remember how to do this nor can i find
what i am looking for
i am trying to update my database when a value is updated into the
database
in one table i have somevalues and a two other peices of information
resolved and dateresolved i want my trigger to update ... more >>
UDF/SP for report by column
Posted by Curious Joe at 10/12/2007 5:00:02 PM
I want to create a UDF or SP that will work something like the
following. I am just not sure how to format the syntax to make it
work.
Function Col_Stats(@lcCol as String, @lcTable as String)
select @lcCol, count(*) as CNT
from @lcTable
group by @lcCol
order by @lcCol
For instance... more >>
Deleting from large table with constrants... slowly
Posted by papalarge at 10/12/2007 4:37:49 PM
I have a large table, over 4 million records at times that I need to
delete a subset from. The problem is that there are 3 foreign key
constraints to this table. I delete all the records from the related
tables, which takes about 1-2 minutes each. Then I attempt to delete
from the main table,... more >>
Newbie Needs Help - Using int seed as Auto number
Posted by Chamark via SQLMonster.com at 10/12/2007 3:52:12 PM
In my table I have a column named Recid and its data type is int length 4,
identity Yes, Indentity Seed 1, Indentity Increment 1. Obviously I need the
Recid as a unique reference and increments much like auto-number in ACCESS.
When I attempt to import data from another source (Access or Excel) ... more >>
QA messages
Posted by Jay at 10/12/2007 3:35:04 PM
SQL Server 2000 QA.
I'm getting an error in a procedure that only happens at runtime. I also
have print/trace statements throughout the proc. However, the error messages
(in red) don't line up with the print statements. I think this is because
they are foing out on stderr and the print stat... more >>
Delete 4% of rows from a very large table (locking issues)
Posted by Michael Kansky at 10/12/2007 2:41:29 PM
Here's the situation:
50 million rows in the table
Very active table, no downtime, gets utilized 24/7/365 by 7500 users.
Need to delete 2 million rows every day(the oldest day data), the table
contains 25 days of data.
Running straight delete takes an hour and locks the table even though... more >>
INDEX -- doesn it still exist in derived table
Posted by at 10/12/2007 2:03:35 PM
Hi,
assume I have this table
Student
StudentID StudentName
12 John
102 David
There is an index called indx_StudentID on Student.Student.
The question is
if I use the the above table as a derived table, will my query still
be using the index or I have ... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
SQL help please
Posted by SteveInBeloit at 10/12/2007 1:48:00 PM
I have two tables. Accounts and AcctDetails.
Accounts has two columns, Account and Desc.
AcctDetails has three columns, Account, Date, and Balance.
there are multiple detail lines per account, just will different dates and
balances.
For each account in Accounts, I need the most recent dat... more >>
Retrieve second row in a table
Posted by Alex at 10/12/2007 1:41:59 PM
Hello,
I know Top 1 will bring back the first row of data in table, but is there
anything that will bring back the second row? I need to compare the two
fields in the latest two rows of data in a log table, and though I can do
Top 1 for the first, is there a simple way to get the second?
... more >>
Local Admin Rights
Posted by PSULionRP at 10/12/2007 1:14:00 PM
What is the general concensus on local admin rights to client machines?
We are running into LOTS of obstacles because infrastructure has taken that
away. And we have third party applications in which our business users need
this. And we are having to tweek registry edit keys and the like beca... more >>
identities after restore
Posted by tobiwan_kenobi at 10/12/2007 1:07:00 PM
I am trying to run a script containing an ‘insert’ on a sql server 2005
database immediately after the database has been restored. But the insert
fails with a ‘Msg 2627, Level 14, State 1, Line 1. Violation of PRIMARY KEY
constraint '<tablename>'. Cannot insert duplicate key in object
... more >>
option to begin returning results ASAP
Posted by Joe at 10/12/2007 12:28:00 PM
Hello,
I am trying to remember an option or set command or ?? that causes a select
command to begin returning results ASAP versus waiting for the entire result
set.
Does anyone know this "thing" and be willing to share?
... more >>
Foreign Key Constraint and Transacation
Posted by Abhijit at 10/12/2007 12:26:01 PM
Sorry for a novice question but I need help to solve this.
I have two tables (parent and child) where one field in child is connected
to primary key in parent using the constraint.
On the constraint, I have enabled "Delete Rule" and "Update Rule" to
"Cascade".
All works fine from ASP.NET ... more >>
Getting max of an item in a list
Posted by Smokey Grindel at 10/12/2007 12:14:16 PM
I have the following table (DDL included below) which has a listing of files
which are tied to parent documents. The parent document can have "revisions"
which are stored in the doc_files table and has a date based on when it was
revised...now I need to get back a list of all the files with th... more >>
How to approach a SP that infrequently runs long or hangs?
Posted by SpankyATL at 10/12/2007 12:04:02 PM
I'm looking for some sort of methodical approach to figuring out what a
stored procedure that runs about 100 times a day, 24/7 would very
infrequently appear to hang or run very long. I'm new to my current company
and this is something they've asked me to look into. The sp in question
usua... more >>
Strange ISNULL behavior
Posted by Jay at 10/12/2007 11:21:31 AM
I built this test case based on a problem in some code. The condition is
when I knew that the @dateval variable might be null and wanted to return 0.
Normally I do initilize variables in a loop, but expected the ISNULL
function to set the var to 0 when the date was NULL.
Before someone says th... more >>
Strange ISNULL behavior
Posted by Jay at 10/12/2007 11:04:01 AM
(reposted after the news server deleted the original - changed dates from
1900 to 2007)
I built this test case based on a problem in some code. The condition is
when I knew that the @dateval variable might be null and wanted to return 0.
Normally I do initilize variables in a loop, but expect... more >>
need to combine a loop through all databases with my stored procedure
Posted by TG at 10/12/2007 11:02:48 AM
Hi!
I need to run my stored procedure on a monthly basis through all the
databases and spit out a report in Excel.
Here is my stored procedure for the report:
CREATE PROCEDURE usp_DR_Billing (@StartDate datetime,@EndDate
datetime,@PreviousDateEnd datetime)
AS
--insert all the ... more >>
Strange ISNULL behavior
Posted by Jay at 10/12/2007 11:00:21 AM
I built this test case based on a problem in some code. The condition is
when I knew that the @dateval variable might be null and wanted to return 0.
Normally I do initilize variables in a loop, but expected the ISNULL
function to set the var to 0 when the date was NULL.
Before someone says... more >>
Using a case statement within a cursor
Posted by DBA at 10/12/2007 9:38:00 AM
Can I use a case statement within a cursor? What I am working on is, e.g.
declare ACursor cursor for local static
case when tableA.color=red
then
select
tableA.color
tableB.shape
tableC.age
from tableA
left join tableB on tableB.fid=tableA.id
where tableA.id=@Id
else
select
select... more >>
Create table from recordset
Posted by Jose Perdigao at 10/12/2007 5:21:00 AM
Is it possible create a table from a recordset?
thanks
jcp... more >>
Is there a way to get all the default values for a given table and apply the same to in another database.
Posted by Rajesh at 10/12/2007 2:10:28 AM
Is there a way to get all the default values for a given table and
apply the same to in another database.
-----------------------------------
Rajesh Halyal
... more >>
Saving data with button in sql database
Posted by Zeljko Bilandzija at 10/12/2007 2:08:32 AM
Hi,
i don't know how to make this:
I want to insert some data in table on this way; i have button, and in
Button_Click event handler i have integer variable with some data (for
example, variable = 10), and i need to insert this data in database
SomeBase, in table named SomeTable, in colu... more >>
Recommendation for good db design book
Posted by Dave at 10/12/2007 12:55:07 AM
Any good recommendations out there for books dealing with database design?
We use MS SQL Server, but a generic db book will work as well. I'm mainly
looking to leverage SQL for some internal reporting capabilites for another
product, so I'm looking for some pointers on how to construct databases... more >>
Case-sensitive collation question
Posted by Peter Boulton at 10/12/2007 12:00:00 AM
Hi,
Datbase collation setting is SQL_Latin1_General_CP1_CI_AS on 2000 and
Latin1_General_CP1_CI_AS on 2005.
Table definition:
CREATE TABLE [dbo].[newdemo_Prod] (
[prodcode] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CS_AS NOT
NULL ,
[_shortdesc] [varchar] (12) COLLATE SQL_Latin1_Ge... more >>
How to store result to table? Thanks!
Posted by SOHO at 10/12/2007 12:00:00 AM
Dear All,
exec sp_abc()
How to store return result to table?
Thanks!
... more >>
|