Viewing 15 posts - 1,666 through 1,680 (of 2,007 total)
Convert the cursor into a set-based solution.
With the current information from your post, that's the best answer I can give. If you want a better answer, I'd need you to...
May 12, 2011 at 5:11 am
Bear in mind that unlike Ken's solution, this solution will always get the data from the first of last month to the first of this month, regardless of the day...
May 9, 2011 at 6:58 am
SELECT *
FROM YourTable
--Grabs data between the 1st of last month and the 1st of this month
WHERE date1 >= DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE())-1,0),
AND date1 < DATEADD(MONTH,DATEDIFF(MONTH,0,GETDATE()),0)
May 9, 2011 at 5:01 am
What you're talking about isn't a job for SQL. What are you actually trying to achieve?
If you insist, you could do it in a few ways. One such would be...
May 6, 2011 at 10:28 am
Those tables are awful. . . what is the purpose of this?
--Test data, two simple tables since you didn't supply DDL
DECLARE @table1 AS TABLE (col1 CHAR(5), col2 CHAR(2), col3 CHAR(3))
INSERT...
May 6, 2011 at 8:42 am
agh100 (5/5/2011)
Well that was even better...
Well, that depends 😉
Best bet is to run some tests on your own data, or knock-up some test data to play with.
Try this to get...
May 5, 2011 at 9:58 am
Speed is the name of the game, and I suspect that if you try this code on a tree with a couple of million nodes then you'll see it chew...
May 5, 2011 at 4:57 am
Off the top of my head: -
DECLARE @sample AS TABLE (PersonID INT, Position NVARCHAR(50), ParentPersonID INT)
-- Insert some sample data into the table based on the structure shown above
INSERT INTO...
May 5, 2011 at 4:29 am
An alternative to CASE: -
--Build some test data since you didn't supply any
DECLARE @blablabla AS TABLE (UnitCost MONEY, UnitPrice MONEY)
INSERT INTO @blablabla
SELECT 0, 1.50
UNION ALL SELECT 1.12, 1.45
UNION ALL SELECT...
May 5, 2011 at 3:55 am
Steve Jones - SSC Editor (5/4/2011)
May 4, 2011 at 10:20 am
Are you running SQL Server 2000? I assumed you're running 2008 since that is the forum you posted in.
May 4, 2011 at 10:08 am
This script came from one of the many blogs that I read - sorry but I can't remember which one right now.
WITH doc_db AS (
SELECT Object_schema_name(objectid) AS object_schema,
...
May 4, 2011 at 9:45 am
No problem. Bear in mind that there may be faster ways to accomplish your task 😉
May 4, 2011 at 9:33 am
--First, lets build some test data, since you didn't supply any I've used a simple table
DECLARE @table AS TABLE (mydate DATETIME)
;WITH testdata AS (
SELECT...
May 4, 2011 at 3:25 am
Something like this?
DECLARE @MaxValue INT, @MinValue INT
SET @MaxValue = 500
SET @MinValue = 1
SELECT * FROM (SELECT columns, ROW_NUMBER() OVER (ORDER BY key ASC) AS rownumber
...
April 28, 2011 at 2:53 am
Viewing 15 posts - 1,666 through 1,680 (of 2,007 total)