Viewing 15 posts - 2,431 through 2,445 (of 2,462 total)
Oky Doky.
Just got back from vacation and wanted to get to this ASAP. I am not optimizing this query, just getting the desired results for now.
First, no UDF needed....
-- Itzik Ben-Gan 2001
July 23, 2012 at 5:05 pm
ChrisM@home (7/20/2012)
XMLSQLNinja (7/18/2012)
...There are other ways to do this but using recursion is generally the fastest.
Recursion is the third fastest; CLR > "Quirky Update" > rCTE > cursor > triangular...
-- Itzik Ben-Gan 2001
July 23, 2012 at 3:43 pm
Just got back from vacation and wanted to address this one first...
I must be missing something but I don't see how that recursive CTE (as much as I like...
-- Itzik Ben-Gan 2001
July 23, 2012 at 2:55 pm
First thought was that we would connect to current db and do updates directly (validating fields before update).
Good Grief! First and foremost - NEVER do that. As a DBA,...
-- Itzik Ben-Gan 2001
July 18, 2012 at 11:22 am
First, by "count of" sales I assume you mean SUM of sales. Otherwise we'd be looking at a result set a little more like:
WeekEndDate SalesTotal
2011-01-07 1
2011-01-14 1
2011-01-21 1
2011-01-28 1
Lets try...
-- Itzik Ben-Gan 2001
July 18, 2012 at 10:12 am
Sean Lange (7/18/2012)
See if this article helps. http://www.sqlservercentral.com/articles/T-SQL/68467/%5B/url%5D
Jeff's article is certainly a must-read on this topic.
-- Itzik Ben-Gan 2001
July 18, 2012 at 8:54 am
a2zwd (7/18/2012)
I have a table which holds the running total.
DECLARE @CumCredit TABLE(RowId INT, CustomerId INT, TransId INT, Pts INT, RunningTotal INT)
INSERT INTO @CumCredit VALUES(1,123,121,10,10), (2,123,131,20,30), (3,123,141,15,45)
New resultset which needs to...
-- Itzik Ben-Gan 2001
July 18, 2012 at 8:32 am
harri.reddy (7/17/2012)
hii need to add my user name into ssms,how to login first in order to add another user.
like sa or what password?
First, a little more detail would help here....
-- Itzik Ben-Gan 2001
July 18, 2012 at 7:42 am
SQLSACT (7/17/2012)
How would I setup a script to copy files from a shared location on one server, to a shared location on another server?
The extension of the files would...
-- Itzik Ben-Gan 2001
July 17, 2012 at 9:53 am
dndaughtery (7/17/2012)
I was told someone interviewing me would ask this. In my 7 years of DB Development Ive never had a...
-- Itzik Ben-Gan 2001
July 17, 2012 at 9:19 am
-- Sample code
CREATE TABLE #T(ID INT, Unit INT)
INSERT INTO #t
SELECT 1,33 UNION ALL
SELECT 2,33 UNION ALL
SELECT 3,25 UNION ALL
SELECT 4,55 UNION ALL
SELECT 5,55
-- Query
SELECT MAX(ID) ID, MAX(Unit) Unit
FROM #t
GROUP BY...
-- Itzik Ben-Gan 2001
July 16, 2012 at 7:29 am
Sean Lange (7/12/2012)
Not sure if what you posted produces what the OP wants but this...
-- Itzik Ben-Gan 2001
July 12, 2012 at 10:41 am
I think this is what you are looking for.
-- Sample data
DECLARE @salesStore TABLE([CustomerID] VARCHAR(20));
DECLARE @MyTable TABLE(val varchar(20));
INSERT INTO @salesStore VALUES ('xxx'),('yyy'),('zzz');
-- Insert statement
INSERT INTO @MyTable
SELECT * FROM
(
VALUES ('Store'),('CustomerID'),('int'),('10'),('Sales'),('CustomerID'),('PK_Store_CustomerID')
)...
-- Itzik Ben-Gan 2001
July 12, 2012 at 9:59 am
CELKO (7/11/2012)
SQL is an abstract model of data. We...
-- Itzik Ben-Gan 2001
July 12, 2012 at 7:45 am
schleep (7/11/2012)
On one SQL server (2 instances), we get the following error on setuser.
Could not obtain information...
-- Itzik Ben-Gan 2001
July 11, 2012 at 12:41 pm
Viewing 15 posts - 2,431 through 2,445 (of 2,462 total)