Viewing 15 posts - 7,621 through 7,635 (of 8,731 total)
I hope that you're trying to eliminate this horrible design to have a properly normalized table.
You can accomplish using the 8KDelimitedSplitter[/url] and CROSS TABS[/url]
SELECT MAX( CASE WHEN LEFT( Item, 1)...
October 8, 2013 at 10:07 am
Here's something for you to start with. To understand this method called CROSS TABS, you could visit this article: http://www.sqlservercentral.com/articles/T-SQL/63681/
To learn how to make it dynamic, use part 2: http://www.sqlservercentral.com/articles/Crosstab/65048/
WITH...
October 8, 2013 at 9:37 am
What about normalizing data?
October 8, 2013 at 8:39 am
sathiyan00 (10/8/2013)
with Improved SQL 8K “CSV Splitter” Function its taking around 25 sec
with xml its taking around 30sec
with substring its...
October 8, 2013 at 8:18 am
If you wan't for display, you can convert to string using convert.
To remove seconds from the datetime, you can do something different.
Either you specify the exact time to start or...
October 7, 2013 at 5:37 pm
Use it as any other TVF
DECLARE @String varchar(100)='123,0.934,98,928.34,987.45'
SELECT *
FROM dbo.DelimitedSplit8K(@String, ',')
WHERE ItemNumber IN(3,5)
October 7, 2013 at 5:07 pm
Using a Tally Table (or in this case a CTE) it's really easy to do it.
Here's an example:
WITH e1(n) AS(
SELECT * FROM (VALUES(1),(1),(1),(1),(1),(1),(1),(1),(1),(1))x(n)
),
e2(n) AS(
SELECT e1.n FROM e1, e1 x
),
e4(n) AS(
SELECT...
October 7, 2013 at 5:04 pm
Where are you checking the results? The grid from SSMS won't show line feeds.
October 7, 2013 at 4:51 pm
From some point of view, 0.1538461 is almost equal to 15.385%
What's your question? What do you need? Couldn't you do it on the front-end?
October 7, 2013 at 12:19 pm
Using SQL Server 2012, you could use TRY_CONVERT or TRY_CAST which will return a NULL value when a conversion can't be made.
Another option is described on the following article
http://www.sqlservercentral.com/Forums/Topic1028368-203-1.aspx
Here's...
October 7, 2013 at 9:16 am
And that's why you should post DDL with your questions. And as this is a SQL Server site, you should tell us that you're not using SQL Server :-D.
October 7, 2013 at 7:44 am
Maybe you could try a CROSS-TABS approach.
SELECT location_name,
MAX( CASE WHEN month = '2008-03' THEN total_offices ELSE 0 END) [2008-03],
MAX( CASE WHEN month = '2008-04' THEN total_offices ELSE 0 END) [2008-04]
FROM...
October 5, 2013 at 6:06 pm
Here are some suggestions that might be wrong but I can't test performance without actual knowledge of your environment:
- Instead of using a CTE, use a temp table to insert...
October 4, 2013 at 3:09 pm
You might want to add a column to your queries, using ROW_NUMBER().
Here's an example, but without some data more similar to the real data, it's hard to give a good...
October 4, 2013 at 10:54 am
SrcName (10/4/2013)
you can try on this way:
select * from TABLE1 t join
(...
October 4, 2013 at 9:51 am
Viewing 15 posts - 7,621 through 7,635 (of 8,731 total)