Viewing 15 posts - 301 through 315 (of 1,347 total)
SELECT j.job_id
FROM Jobs As j
INNER JOIN Activities As a
ON (j.job_id = a.job_id)
WHERE a.activity_type_id IN (1, 3)
GROUP BY j.job_id
HAVING Count(*) = 1
August 21, 2006 at 5:09 pm
Use fn_split()
http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=302389#bm302391
August 21, 2006 at 12:41 pm
We don't know enough about the tables to determine if a JOIN is correct.
>>select mem_id from dbo.conc_table00
If mem_id is not unique, using a JOIN instead of EXISTS will generate dupes...
August 21, 2006 at 11:07 am
DISTINCT works across all columns in the resultset, not just the column immediately after the keyword DISTINCT.
SELECT DISTINCT id, name gives you all the unique id AND name combinations. If...
August 18, 2006 at 3:45 pm
Did you mean derived table ?
As in (using system tables for an example):
Select TableName, NumberOfColumns
From
-- Parenthesis starts derived/virtual table definition
(
Select Object_Name(id) As TableName, Count(*) As NumberOfColumns
From...
August 18, 2006 at 2:44 pm
You don't need CASE .. WHEN, it's just a simple OR:
WHERE
(@Status_code IS NOT NULL AND status_code = 10) OR
(@status_code IS NULL AND status_code IN (9,11,12) )
August 18, 2006 at 12:07 pm
-- Table for sample data
Create Table #Test
(
Name varchar(20),
Event varchar(20),
Time datetime
)
-- Populate with sample data
Insert Into #Test
Select 'Name1', 'Start', '8/16/06 8:00 AM' Union All
Select 'Name2', 'Start', '8/16/06...
August 18, 2006 at 10:34 am
If you want to start by looking at the SQL, then some warning signs to look for:
- Use of sub-SELECTS within the main SELECT. Creates cursor-like sluggishness
- Use of user-defined...
August 17, 2006 at 12:48 pm
>>I think i'll start writing the SP
That's 1 approach.
A better approach in the long run would be to design the database correctly using standard normalization techniques.
If a "story" can have...
August 17, 2006 at 10:07 am
Use fn_split() function:
http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=157
This constructs a table, which you join to instead of using IN ().
August 17, 2006 at 9:45 am
Why on earth would you index a float data type ?
A float is an approximate number, indexing it makes no sense.
August 17, 2006 at 9:31 am
The error is pretty explicit is it not ?
It's telling you it expects @cmd to be of type 'ntext/nchar/nvarchar', but you've declared it as varchar.
August 17, 2006 at 9:29 am
>>an identity value is a bad canidate for a clustered index because of all of the split pages at the end of the file.
On the contrary, clustering on an identity...
August 17, 2006 at 9:25 am
>>this is not working
Need to be a bit more specific.
What is the actual error you're getting ? Are the tables involved in referential integrity ? You can't drop tables if...
August 17, 2006 at 9:22 am
sp_help and sp_helpconstraint
August 16, 2006 at 2:23 pm
Viewing 15 posts - 301 through 315 (of 1,347 total)