Viewing 15 posts - 76 through 90 (of 149 total)
That is a terribly silly requirement.
OK, then how about this:
IF DB_NAME() = 'Master'
BEGIN
PRINT '**************************************************************************************'
PRINT '************** Master db is selected. Please select correct database *****************'
PRINT '**************************************************************************************'
END
ELSE
BEGIN
{do all the...
May 17, 2006 at 9:59 am
EDIT: SQLBill trumped me. Sorry for the double post.
Actually, check out the USE keyword. That tells SQL Server which database to apply the changes to.
E.g.,
USE pubs
SELECT *
FROM...
May 17, 2006 at 8:29 am
Assuming that the intent of this query is to create a cross-tab, you pretty much have it.
Although, if you're using SQL Server 2005, you can look into the PIVOT keyword.
May 17, 2006 at 8:12 am
I don't see anything in that statement involving a subquery. Do you have other code wrapped around it, perhaps error checking code?
May 17, 2006 at 8:05 am
Er, a much more efficient query (in case performance is an issue) would be:
SELECT Equip.EquipID, Equip.DivCode
FROM EquipmentTable Equip
LEFT JOIN DivisionTable Div
ON Equip.DivCode = Div.DivCode
WHERE Div.DivCode IS NULL
The LEFT JOIN will...
May 17, 2006 at 8:01 am
You'll want a User-Defined Function to concatenate the values.
CREATE FUNCTION ConcatAccrual (@vEmp int)
RETURNS varchar(500)
AS
BEGIN
DECLARE @myString varchar(500)
SET @myString = ''
SELECT @myString = @myString + EmpTable.Accrual + ' '
FROM EmpTable
WHERE EmpTable.EmpNo...
May 16, 2006 at 6:37 am
We should probably look into creating a sticky post with a FAQ. This question, in particular, seems to come up two or three times a week.
CREATE FUNCTION ConcatID (@vName...
May 16, 2006 at 6:27 am
Depending on the amount and type of reporting you are doing, storing the Duration as a computed column may be beneficial to you. It has some cost to it,...
May 16, 2006 at 6:10 am
You need to specify your table. E.g.,
UPDATE myTable
SET sent = 1
...
May 15, 2006 at 7:46 am
The problem is that your SELECT statement is replacing the value of @@AttachMe with each row.
Try this instead (replacing the semicolon with whatever character should separate one filename from the...
May 12, 2006 at 6:19 am
Check out OPENXML in Books Online, and the related topics. There's actually quite a bit of useful info in there about how to import XML files.
May 12, 2006 at 5:47 am
That would depend, in some part, in how exactly you are passing those values into your query. Are you building the query on the fly in ASP? Is...
May 12, 2006 at 5:43 am
The first is mostly correct, but you still have a couple less than comparisons with zeroes in there.
SELECT * FROM SilokE WHERE ((SilokE.mhlka) Like ('3'))
AND (((SilokE.id) Not In
(select id...
May 11, 2006 at 12:57 pm
This is very similar to the classic problem of only searching by the day, and losing the last day from the results.
I'm willing to bet that these datetime values are...
May 11, 2006 at 12:30 pm
Is one of the fields in your query there the identity field? If so, that won't work unless you have the IDENTITY INSERT set to ON.
If it's not, then...
May 11, 2006 at 12:07 pm
Viewing 15 posts - 76 through 90 (of 149 total)