Viewing 15 posts - 46 through 60 (of 149 total)
instead of just doing a select all into the table:
INSERT INTO Table1
SELECT * FROM Table2
You might want to try a not exist in a where clause:
INSERT INTO Table1
SELECT *
FROM Table2...
April 17, 2008 at 7:35 am
Try this:
DECLARE @vcStart varchar(6),
@vcEnd varchar(6)
SET @vcStart = CONVERT(char(4), YEAR(DATEADD(month, -6, GETDATE()))) + RIGHT('00' + CONVERT(varchar(2), MONTH(DATEADD(month, -6, GETDATE()))), 2)
SET @vcEnd = CONVERT(char(4), YEAR(GETDATE())) + RIGHT('00' + CONVERT(varchar(2), MONTH(GETDATE())), 2)
SELECT Whse_Code, SUM(Sales_Qty) AS...
April 17, 2008 at 7:11 am
Try using your select statement as derived table like the following:
SELECT ID,
[Date],
TimeGroup,
CallCount
FROM (SELECT 1 AS ID, -- dummy value
CONVERT(VARCHAR(10), s.endtime, 101)...
April 14, 2008 at 9:58 am
Try this:
UPDATE t
SET points = points + 1
FROM #Temp6 t
INNER JOIN (SELECT ConsultantId
FROM volume
GROUP BY ConsultantId
HAVING SUM(PurchaseAmount) > 1000) v
ON t.ConsultantId = v.ConsultantId
WHERE DeactivationDate BETWEEN @StartDate AND @EndDate
AND Active =...
April 3, 2008 at 8:50 am
Check out the SUBSTRING function.
It takes three parameters:
1. The expression to search
2. The start place of what to return
3. The length of characters to return. In...
April 2, 2008 at 10:22 am
This one is going to be a little more difficult. You are going to have to combine the date and time into a datatime field and then find the...
April 2, 2008 at 7:38 am
This all has been some very good food for thought. It looks like the hardware folks here at my company are going to go the way of either a...
April 1, 2008 at 1:02 pm
Using the derived tables is one solution. Here is another that looks very similiar:
SELECT p.name, p.dob, c1.charge, c2.charge, c3.charge
FROM patients p
LEFT OUTER JOIN charges c1 ON...
March 31, 2008 at 2:10 pm
Michael,
Thanks for the info. We are using the ESX licensed version of VMWare. We have run into quite a few problems with the freeware version on other applications...
March 31, 2008 at 9:27 am
Matt,
Would not an 'EXISTS' clause be cleaner and more efficient in this situation or not? I am just asking this because I am curious, and I have been seeing...
March 28, 2008 at 12:13 pm
I have a feeling you are using an '=' in your camparison to the subquery. Try using an 'IN' instead. This way it will compare the left side...
March 28, 2008 at 12:00 pm
Two ways that I can think of are:
1. import the data into a staging table that has an identity column and then run two insert statements to split the...
March 28, 2008 at 11:46 am
Another possibility is using the exists and not exists clause
in place of your {not in} clause try this:
select * from tableA a
where not exists (select null from tableB where id...
March 28, 2008 at 11:39 am
Yes, you can apply it to the entire column. Here is an example of an update sql that take a full name and parse it into the first and...
March 26, 2008 at 1:22 pm
If you will always be checking the same table, then there is a way to create a function to check a particular passed in column for a particular passed in...
March 25, 2008 at 10:54 am
Viewing 15 posts - 46 through 60 (of 149 total)