Viewing 15 posts - 2,176 through 2,190 (of 2,458 total)
Using this sample data:
--Adjust for the number of days of sample data you would like
DECLARE @days int = 1000;
IF OBJECT_ID('tempdb..#sales') IS NOT NULL
DROP TABLE #sales;
CREATE TABLE #sales
(sale_id int identity primary...
July 29, 2013 at 3:28 pm
I asked this same question a few months back and got some good replies; just thought I'd share this:
http://www.sqlservercentral.com/Forums/Topic1397471-391-1.aspx
Check this out:
SELECT CAST(REPLICATE(CAST('' AS int),10) AS char(10)) AS...
July 25, 2013 at 1:15 pm
Tobar (7/25/2013)
DECLARE @d DATETIME = '07/25/2013 10:11:12.345';
SELECT FORMAT ( @d, 'yyyy dd mm hh mm ss')
2013 25...
July 25, 2013 at 1:01 pm
Eugene Elutin (7/25/2013)
Alan.B (7/24/2013)
Erland Sommarskog (7/24/2013)
Alan.B (7/24/2013)
Why is the SELECT@x=@x+ method not guaranteed to work?
Why would it?
See this KB article Pay particular attention to the first sentence under Cause.
I...
July 25, 2013 at 12:30 pm
Erland Sommarskog (7/24/2013)
Alan.B (7/24/2013)
Why is the SELECT@x=@x+ method not guaranteed to work?
Why would it?
See this KB article Pay particular attention to the first sentence under Cause.
I say it would...
July 24, 2013 at 4:38 pm
This would do the trick:
SELECT
CASE
WHEN ISNULL(rate,100)=100 THEN 1
ELSE 0
END AS Rate
FROM {yourtable}
July 24, 2013 at 4:01 pm
Erland Sommarskog (7/24/2013)
SELECT substring(list, 1, len(list) - 1)FROM (SELECT list =
(SELECT DISTINCT name + ','
...
July 24, 2013 at 3:57 pm
A couple techniques:
SELECT RIGHT(abc_col1,len(abc_col1)-2)
FROM tableA
SELECT REPLACE(abc_col1,'SH','')
FROM tableA
July 24, 2013 at 2:54 pm
Here's another way... it's kind of a "Quirky-Coalesce":
-- sample data
DECLARE @Production_Product TABLE (name varchar(10));
INSERT INTO @Production_Product VALUES ('aaa'),('bbb'),('ccc'),('ccc');
DECLARE @listStr varchar(max)='';
SELECT @listStr=@listStr+
CASE
WHEN @listStr='' THEN ''+name
ELSE ','+name
END
FROM (SELECT DISTINCT name FROM...
July 24, 2013 at 2:46 pm
NineIron (7/24/2013)
July 24, 2013 at 1:14 pm
Luis Cazares (7/18/2013)
No, you can't because the alias doesn't exist when the JOIN is processed.
You can get around that doing something like this (using my own sample code...
July 18, 2013 at 1:59 pm
You can. It's hard to work with what you posted so I created the following sample code to demonstrate how you would join two tables in the way you are...
July 18, 2013 at 1:45 pm
As Sean said, you need an ORDER BY statement.
I created some sample data and a query that you could use for reference. I am a fan of using the...
July 17, 2013 at 3:13 pm
My object naming needs to be cleaned up a little but I think you are looking for something like this:
IF OBJECT_ID('tempdb..#tableDataPrep') IS NOT NULL
DROP TABLE #tableDataPrep;
IF OBJECT_ID('tempdb..#tableData') IS NOT NULL
DROP...
July 17, 2013 at 10:51 am
You can do something like what I did below. I'm not 100% clear about what you are trying to do but this should help....
You would have an agent job run...
July 17, 2013 at 9:07 am
Viewing 15 posts - 2,176 through 2,190 (of 2,458 total)