all groups > sql server programming > january 2006 > threads for friday january 13
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
Outer Join and WHERE clause strange behavior
Posted by Mark Williams at 1/13/2006 11:06:01 PM
I am writing a stored procedure to get aggregrate data out of a web site log
table by joining it with a view
DDL for the table:
CREATE TABLE w3cexlog (
pacifictime datetime,
[cs-method] varchar(20),
target varchar(8000),
query varchar(2000),
username varchar(100),
browser... more >>
Selecting Duplicates - all data
Posted by Simon at 1/13/2006 8:50:51 PM
Hi all,
I have found many solutions for selecting duplicates with the most
popular being:
SELECT ColA, COUNT(ColA)
FROM SomeTable
GROUP BY ColA
HAVING count(ColA) > 1
However, what I am after is a query that returns all of columns and all
of the duplicate rows where duplicates exist ... more >>
set theory operations on two tables containing date range data
Posted by peter walker at 1/13/2006 7:01:46 PM
Hi everyone, I was hoping anyone came across implementing set theory
operations on two tables containing date ranges.
In specific the tables are set up as so:
Table A
[client] [start date] [ end date]
a 1 3
a 8 12
b 6 8
b 10 12
c 15 31
Table B
[client] [start ... more >>
Possible to get column number on a bcp_sendrow failure?
Posted by kdd21 NO[at]SPAM hotmail.com at 1/13/2006 5:18:34 PM
I've tried SQLGetDiagRec, which tells me that there was an invalid date
format on a column, but there's no indication of *which* column, and my
table has several date columns in it.
I then spotted some references to SQLGetDiagField with
SQL_DIAG_COLUMN_NUMBER, but I don't get any records back ... more >>
MTS Query
Posted by lara169 at 1/13/2006 4:38:45 PM
Hi,
This is a silly question
1. What the precausions we need to take care while coding a procedure, if we
have an MTS. Do we need to explicitly mention the Transactions in the sps ?
And what about setting the Value of 'XACT_ABORT' .
2. Another situation in the same.
Normally all our ma... more >>
Signalling between two applications
Posted by Ryan Pedersen at 1/13/2006 4:15:36 PM
I have two applications that pass data in one direction via a MSMQ.
"Scheduler" application looks at the database and finds records that
need to be worked on. It creates object for those records and puts
them in the message queue. The "Worker" application is monitoring the
queue for new messag... more >>
handle errors in trigger
Posted by Vikram at 1/13/2006 3:51:25 PM
How to handle error in trigger.
i m inserting record in other table in after insert trigger. but if insert
statement in trigger has error, procedure quits with error and i cannot use
@@error to check it
... more >>
Replce SPACES in values
Posted by Mike Kansky at 1/13/2006 3:26:24 PM
I have a task before me that i need help with.
I have values in table that look like this:
'MY TASK' [random_operator] 'VERY ANNOYING'
I need to replace SPACES that are inside quotes with '_?'
Only values that have quotes around them should have their spaces replaced
with '_?'
Any idea... more >>
Don't see what you're looking for? Search DevelopmentNow.com.
Moving a database
Posted by Dean at 1/13/2006 3:26:02 PM
I have a small customer with a 2GB database. They recently added a RAID 5
array and RAID10 array to their server. I want to move the data files to the
RAID 5 and the log files to the RAID 10. Is there a script/command I can use
to move it or is it easier to just backup the database and then us... more >>
Verify existing Child Data
Posted by tarcila NO[at]SPAM infomercial.tv at 1/13/2006 3:15:09 PM
Hello,
Does anybody has any clue if its possible to verify if a record has any
related data?
Let me try to explain these a better, i'd like to show the delete
option only when no data related with the specifc Record is available
and not return an error message if the data that they try to d... more >>
SQL for custom paging solution
Posted by jonefer at 1/13/2006 1:49:02 PM
When I try to compile this (complete Store Procedure below)
I get the following error:
The select list for the INSERT statement contains fewer items than the
insert list.
I know what is causing this to bomb is the complex Grouping (which I've
marked below as ---COMPLEX GrOUPING
(this gro... more >>
Dynamic SQL and @@Rowcount
Posted by dpc at 1/13/2006 1:47:03 PM
How can I get the RowCount of a SQL that has been executed in a dynamic SQL.
@@RowCount appears to return the rowcount for the EXEC of sp_executesql.
T.I.A.
E.g.:
DECLARE @TblGen Table
(relation nvarchar(50),
attribute nvarchar(50),
sql nvarchar(255),
rtncde int,
c... more >>
Most recent data point?
Posted by Michael Bray at 1/13/2006 12:34:54 PM
I have a table that stores data points for several different data sources.
The general format is:
DECLARE @Data TABLE
(
DataID int,
TimeCollected int,
DataValue decimal(9,9)
)
INSERT @Data VALUES (1, 1000, 0.75)
INSERT @Data VALUES (1, 1001, 0.69)
INSERT @Data VALUES... more >>
Update Query!!!!
Posted by Adam Knight at 1/13/2006 12:14:39 PM
Hi all,
I have the following query that returns a two column result set.
SELECT
s.standard_id, si.standard_item_id
FROM
standards s
INNER JOIN
standard_items_bk si
ON
s.parent_id = si.standard_id
AND
s.idx = si.idx
Sample results:
standard_id | standard... more >>
"did you mean" feature
Posted by Fabio Cavassini at 1/13/2006 11:46:26 AM
Having a list of words in a table...haw can I make with SQL a "did you
mean" search?
for example..
Having a table with these data:
hello
hallo
hi
lup
hai
If I look for "hollo" it should return "hello", "hallo"
I know this could be a very complex algorithm, but I'm looking for it'... more >>
"No more data available to read" error
Posted by MittyKom at 1/13/2006 11:43:03 AM
Hi All
"No more data available to read" error is thrown by database driver when
connections max out on SQL Server. Does any one know what this means and how
can i resolve this issue? An application developed in Java uses SQL Server
for data storage. Thank you in advance.
... more >>
Alter a constraint?
Posted by Rick Charnes at 1/13/2006 11:28:30 AM
Is there a way to add a column to a PRIMARY KEY constraint (without
deleting and recreating it?) Thanks.... more >>
Help! Query Question.
Posted by Yoyo at 1/13/2006 11:18:02 AM
Hi all,
I'm new to SQL programming, and I am having a hard time figuring this one out.
I have a table containing the following information:
Activity Cost Account Hours
1 A 100
1 B 200
1 C 250
1 D 100
2 A 600
2 F 200
3 B 100
3 C 200
3 D 400
I would like to create a view that will... more >>
DB Change Deltas HELP!!!
Posted by Tim Greenwood at 1/13/2006 11:08:32 AM
I know there are tools that can look at two different versions of a database
and generate a script to take one to match the other. I cannot seem to find
anything suitable. I thought Visio could do this but I'm not seeing
anything in the 2003 Pro version.
We have major revisions that need ... more >>
Journal table for a database
Posted by Senthilkumar at 1/13/2006 11:08:30 AM
Hi,
I am using a SQL Server 2000 database with a VB.net program and uses
Integerated security. I want to log all the changes made to any table
data(whether addition, deletion, updation) to a single table by all the
users.
Is this possible by way of a common trigger. I dont want to use th... more >>
Performance of UPDATE commands on individual records
Posted by Josh McFarlane at 1/13/2006 10:41:49 AM
Ok, I'm at a crossroads in my program.
I've got a program that needs to throw an SQL update command to update
some individual records.
>From an efficiency standpoint, does SQL handle the UPDATE command
differently if the field is the same as the old field?
IE
Is it worth doing a string... more >>
SQL profiler
Posted by SimonZ at 1/13/2006 10:26:39 AM
I would like to see what's happening on the database which I'm database
owner.
But when I open SQL profiler it requires that I'm a member of sys admin
server role.
What now?
I'm dbo of that database(I created it) but I can't see what's happening
there.
Is there some way to avoid th... more >>
Insert into table with union?
Posted by Lasse Edsvik at 1/13/2006 10:21:04 AM
Hello
I was wondering howto insert into a new table with a union query,
something like:
SELECT * INTO #New FROM
SELECT SomeNmbr FROM #A
UNION
SELECT SomeNmbr FROM #A
... more >>
Max question
Posted by Lasse Edsvik at 1/13/2006 10:18:58 AM
Hello
I was wondering if you guys could help me with a simple max select,
Im trying to find the max value where SomeNmbr doesnt follow the increment
step of 1. And no, im not trying to fiddle with the IDENTITY(1,1) thing :)
In this case 4
CREATE TABLE #A (
SomeNmbr int
)
INSERT ... more >>
Standard Deviation
Posted by Bahman at 1/13/2006 10:10:02 AM
Hello!
I have a problem with my sql server.
When I run: select stdev(sales), avg(sales) from salestable
I get: standard deviation: 65, average: 63
Which is garbage.
What would be the correct syntax to get the stdev? What would I have to tell
the sql server?
Thank you very much fo... more >>
Statistics Deadlocking
Posted by JI at 1/13/2006 9:58:38 AM
I have a statistic that has been created by SQL Server automatically that is
deadlocking. I understand how it deadlocks but would like some advice on the
best fix. My thoughts are dropping the statistic or creating an index on the
column.
Has anyone else had experience with stats deadlockin... more >>
SQL Syntax Question
Posted by Greg Smith at 1/13/2006 9:51:38 AM
Is it possible to pass a table name to a stored procedure?
I have a ton of stored procedures that do the same basic thing, just on
different tables.
Can I pass a table name, and, if so can you give me an example?
Ant help is greatly appreciated.
... more >>
generic audit trail best practice questions
Posted by jason at 1/13/2006 8:56:34 AM
hello everyone,
so i have the need for an audit trail for certain activities. ideally i
would like a generic audit trail table, that denotes the kind of
activity, the entity reference it was performed on, and the entity
reference it was performed by.
for example, there are currently entitie... more >>
sp_OAGetProperty procedure is giving error
Posted by vineet.jsl NO[at]SPAM gmail.com at 1/13/2006 8:49:41 AM
i am encountering a problem when calling a web service from the stored
procedure.
the sp_OAGetProperty procedure is not running fine.
at this line the error generated is
0x80020006 ODSOLE Extended Procedure Unknown name.
do anyone have any idea about how to solve this problem. i need he... more >>
append a string to all the values in a column SQL
Posted by gtg974p NO[at]SPAM gmail.com at 1/13/2006 8:42:27 AM
Sub: Append a string to all the values in a column SQL
Hi all,
This might be a very simple query. But I am new to SQL programming.
Hope someone can help me.
I have a table ---
1634 Fred los angeles
123 Sam
1245 abc
1231 ....
1278 .....
578 ... more >>
BCP IN: create table on-the-fly
Posted by Test Test at 1/13/2006 8:32:00 AM
Hello!
I have a BCP file (.BCP) and I want to do a BCP IN but I don't have a
table associated with it. (Lets say table got dropped). I am curious if
there is a way to create a table on-the-fly while doing BCP IN? Any neat
solution?
Thanks!
*** Sent via Developersdex http://www.develope... more >>
Constraint
Posted by Olav at 1/13/2006 7:48:06 AM
Hi,
we want to check the paystatusid in the table Treatement
CREATE TABLE [Treatement] (
[treatementid] int IDENTITY(1,1) NOT NULL ,
[customerid] int NOT NULL ,
[paystatusid] int NOT NULL , .....
and
CREATE TABLE [Paystatus] (
[paystatusid] int IDENTITY(1,1) NOT NULL ,
[customerid] int... more >>
Moving tempdb
Posted by Emma at 1/13/2006 7:31:03 AM
How do I move tempdb to another drive on the same server?
Thanks
Emma... more >>
complicated Join - duplicate row problem
Posted by Jeff User at 1/13/2006 6:38:33 AM
Hi
I had a similar problem awhile back and it was solved here. Now it has
gotten more complex. I have removed uneeded stuff here to keep this
simple.:
I am sure I know why I am getting the results I am, but don't know
how (or if) there is a way around it. If someone can help, I will be
mighty ... more >>
Why SQL2k and SQL2005 Return Different Order for sysindexkeys?
Posted by Mac at 1/13/2006 4:56:03 AM
I have an exact table in both SQL2000 and SQL2005.
But the return order of 'colid' for the first key is different! (only the
first key, not the others).
My select query is:
"SELECT [indid], [colid] FROM AWT..sysindexkeys
where [id] in ( select [id] from AWT..sysobjects where [name]='Vend... more >>
Obtaining different timings for the same process??
Posted by Enric at 1/13/2006 4:49:02 AM
Dear fellows,
The following loop bring me differents results, execute one after one (among
them a truncate table, of course):
DECLARE @loop as integer
set @loop = 1
while @loop < 10000
begin
insert into A_test(id,nombre,ape) values(@loop,'a','aadfasdf')
set @loop = @loop ... more >>
Is OR so bad?
Posted by tonicvodka at 1/13/2006 4:30:16 AM
Hi all !
I have the following query which runs ok:
SELECT
estates.l_memberID,
member.l_memberID
FROM
estates
left join companies on estates.l_companyid=companies.l_companyid
left join multimedia on multimedia.l_estateid=estates.l_estateid and
isnull(N_INDEX,1)=1
left join member (NOLOC... more >>
Inserting same identity value into two linked tables
Posted by Amir at 1/13/2006 3:09:13 AM
Hi,
I have two tables which has 2 linked fields, as David Portas posted in
'Field value determines whether there is extra info that should be held
about that record':
CREATE TABLE events (event_no INTEGER NOT NULL PRIMARY KEY, event_type
INTEGER NOT NULL CHECK (event_type BETWEEN 1 AND 10... more >>
Indexing datetime field for selecting dates ranges
Posted by Amir at 1/13/2006 2:53:41 AM
Hi,
I have a table with a smalldatetime field. Some of the queries in my
application are using range searches over that smalldatetime field, such as
selecting all the records within a date range. None of these queries are
selecting records from a specific date/time. They all work on ranges ... more >>
Obtaining total of partial
Posted by Enric at 1/13/2006 2:11:02 AM
Dear all,
I was wondering how do I for obtain the total for the field 'parcial' in the
same query, of course:
SELECT MONTH(DIA_HORAESCRITURA) AS MES,DAY(DIA_HORAESCRITURA) AS DIA,
COUNT(*) AS partial
FROM ABS_DIARIOHISTO
WHERE DIA_SUCURSAL = 81
GROUP BY MONTH(DIA_HORAESCRITURA),DAY(HO... more >>
Extracting from linked tables into pivot
Posted by CyberFox at 1/13/2006 1:56:02 AM
Hi there,
I've managed to come this far and I need a bit of help to finalise. I'm
extracting records correctly using the following:
select substring(D.MStockCode,1,3) as Style,
sum(case month(D.MLineShipDate)
when 1 then D.MBackOrderQty*substring(D.MStockCode,17,1) else 0
end) as J... more >>
What's a good SQL server naming convention
Posted by CharlesA at 1/13/2006 1:56:01 AM
Hi folks,
I wonder if any of you in all your wisdom happen to know the URL of a
published web article on a really decent SQL server naming convention
I've obviously googled it, but have come across nothing that has
particularly grabbed me as thorough or especially coherent.
Regards, and t... more >>
|