Viewing 15 posts - 3,241 through 3,255 (of 4,085 total)
Using datapart, you'll lose the leading zeros. Convert it to the format closest to what you want and then clean it up using REPLACE.
SELECT REPLACE(REPLACE(REPLACE(CONVERT(varchar(25), GETDATE(), 120), '-', ''),...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 11, 2012 at 9:12 am
Please do not create duplicate posts for the same topic. It fragments the replies. Please respond in this thread. http://www.sqlservercentral.com/Forums/Topic1281038-392-1.aspx
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 11, 2012 at 9:05 am
GilaMonster (4/11/2012)
Semicolons are statement terminators, as such they should terminate statements, not start them. We don't start sentences in English with fullstops.
T-SQL is a completely different language from English with...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 11, 2012 at 8:52 am
If the ultimate goal is concatenation, then there's no reason to shift columns left. Just do the concatenation as normal.
with mySampleData (id,addr1,addr2,addr3)
AS
(
SELECT'1','123',NULL,'Main St.' UNION ALL
SELECT'2',NULL,NULL,NULL UNION ALL
SELECT'3',NULL,'345','Elm St.'...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 10, 2012 at 11:30 am
Part of the problem is that the OP specified a particular route to the destination when only the destination is important. There are really only three conditions:
Between Friday at...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 9, 2012 at 10:28 am
There are just too many variables to recommend one approach over another. You'll need to test several different approaches to see which one works best with your data.
A table...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 9, 2012 at 7:13 am
Henry Treftz (4/6/2012)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 9, 2012 at 6:49 am
A CTE is part of the following INSERT, SELECT, or UPDATE statement and does not exist outside of that scope. If you need to use the same set of...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 6, 2012 at 3:33 pm
Sorry, misread the SQL.
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 6, 2012 at 3:13 pm
Jeff Moden (4/5/2012)
I guess that I'm still amazed that such a simple structure requires 3 selects to return the hierarchy.
It doesn't. As with almost everything, there are multiple ways...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 6, 2012 at 8:44 am
I think you mean MDX. You cannot directly translate SQL to MDX. Even though there are some superficial similarities, they are completely different languages, because they query completely...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 5, 2012 at 2:47 pm
SSIS requires that each of the records have the same structure. Since your header records have a different structure than your detail records, you can't do this directly in...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 5, 2012 at 2:11 pm
Here is another possibility. Since you haven't provided test data, it's difficult to compare the various methods. This method only scans the table once, but has more logical...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
April 5, 2012 at 8:17 am
Jeff Moden (3/30/2012)
Heh... a Rose, by any other name, is still a Rose.Unless I'm mistaken, all of the examples above all boil down to some form of parent/child relationship.
I'm not...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 30, 2012 at 4:54 pm
Use FOR XML PATH('') to concatenate your string together. There are several articles on how to do this. In my quick scan, this covered the basics well. Creating...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 30, 2012 at 4:35 pm
Viewing 15 posts - 3,241 through 3,255 (of 4,085 total)