Viewing 15 posts - 2,611 through 2,625 (of 3,957 total)
I like your:
VALUES ($)
Wonder where you got that from... 😛
October 8, 2012 at 3:59 am
Here's something that might get you started:
;WITH NullableColumns AS (
SELECT TableName=a.name, ColName=b.name
FROM QA.sys.objects a
INNER JOIN QA.sys.all_columns...
October 8, 2012 at 2:11 am
ChrisM@Work (10/8/2012)
dwain.c (10/8/2012)
ChrisM@Work (10/8/2012)
;WITH WholeRange AS (
SELECT datecol = DATEADD(day,n,d.Startdate)
FROM (SELECT Startdate = MIN(datecol), daysSpan...
October 8, 2012 at 1:50 am
ChrisM@Work (10/8/2012)
;WITH WholeRange AS (
SELECT datecol = DATEADD(day,n,d.Startdate)
FROM (SELECT Startdate = MIN(datecol), daysSpan = 1+DATEDIFF(day,MIN(datecol),...
October 8, 2012 at 1:10 am
Jeff Moden (10/7/2012)
Nagaram (10/7/2012)
;WITH DigitsCTE AS
(
SELECT digit
FROM (VALUES(0), (1), (2), (3), (4), (5), (6), (7), (8), (9))...
October 7, 2012 at 10:05 pm
I find it extremely annoying that this does not work:
DECLARE @Weight FLOAT = 0
,@STDate DATETIME
,@EDate DATETIME
SELECT @STDate=MIN(DATECOL), @EDate=MAX(DATECOL) FROM #SAMPLETABLE
;WITH Tally...
October 7, 2012 at 9:34 pm
midavalo (10/7/2012)
dwain.c (10/7/2012)
First of all, it would be most useful if you put your sample data into consumable form and provide DDL, e.g.:Excuse my ignorance, but what is DDL?
Cheers,
Mike.
DDL=DATA DEFINITION...
October 7, 2012 at 8:45 pm
Jeff Moden (10/7/2012)
dwain.c (10/7/2012)
I don't think this has the same issue that Jeff is reporting about Mark's but it's just another option:
Gosh. Good bit of code, Dwain, but it...
October 7, 2012 at 8:18 pm
First of all, it would be most useful if you put your sample data into consumable form and provide DDL, e.g.:
DECLARE @t TABLE (col1 VARCHAR(10), col2 VARCHAR(10))
INSERT INTO @t
SELECT 'abc',...
October 7, 2012 at 8:13 pm
Is there some reason you can't or won't use a MERGE for this?
CREATE TABLE #Weights
(id INT, shipweight1 DECIMAL(5,2)
,shipweight2 DECIMAL(5,2), shipweight3 DECIMAL(5,2))
INSERT INTO...
October 7, 2012 at 7:59 pm
I don't think this has the same issue that Jeff is reporting about Mark's but it's just another option:
;WITH Tally AS (
SELECT...
October 7, 2012 at 7:29 pm
gravitysucks (10/5/2012)
AND SUBSTRING(LastName,1,1)<>'/' ---??
Yes or:
AND LEFT(LTRIM(LastName), 1) <> '/'
The LTRIM is in case there are blanks only leading up to the slash.
October 5, 2012 at 8:07 pm
ChrisM@Work (9/21/2012)
DECLARE @asd VARCHAR(20)
SET @asd = 'asdaaaadffa'
SELECT
Letter,
Occurrences = COUNT(*)
FROM (
SELECT Letter = SUBSTRING(@asd,n,1)
FROM (SELECT TOP(LEN(@asd)) n = ROW_NUMBER() OVER (ORDER BY (SELECT NULL))
FROM sys.all_columns) tally
) d
GROUP BY...
October 4, 2012 at 11:32 pm
Lowell (10/4/2012)
all these variables are available in 2008 and above, so if you have an audit table, just include some columns for...
October 4, 2012 at 10:49 pm
venus.pvr (10/4/2012)
Not sure if the order of the inserts matter. Else the below would work:DECLARE @a INT
SELECT @a=MAX(empid)+99 FROM dbo.employee
INSERT INTO dbo.employee(empid,name,city)
SELECT @a+ROW_NUMBER() OVER (ORDER BY name),name,city FROM #newuser
-Praveena
I would...
October 4, 2012 at 10:41 pm
Viewing 15 posts - 2,611 through 2,625 (of 3,957 total)