Showing posts with label bit. Show all posts
Showing posts with label bit. Show all posts

Friday, March 9, 2012

Joing Multiple Columns

Hi All,

Bit of a newbie question i'm afraid, so sorry if this is a really
stupid question,

I am not sure if I am trying to do this in the right place as I am sure
SQL Server has a far better way of doing this

What I am trying to do is join the contents of several columns and
present the entry into a new column. the entries of all the columns I
am trying to join are different types such as dates and numbers. I want
to join all columns as a text string. To make it just a even more
tricky I wish to insert a # between all fields.

Just in case my poor description has got you thinking What the F*&K
here is an example of what I am trying to do

C1 C2 C3 C4 C5
Ian 1234 22/02/2006 123456789 Ian#1234#22/02/2006#1234567890
I have been trying to do this in the Formula in the design veiw of the
table.

Any Advice would be fantastic.

Many Thank

IanTry:

select
C1 + '#' + cast (C2 as varchar (10)) + '#' + convert (char (10), C3,
103) + '#' + cast (C4 as varchar (10))
from
MyTable

--
Tom

----------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"Crumb" <rowan.ian@.gmail.com> wrote in message
news:1140655591.245227.133490@.f14g2000cwb.googlegr oups.com...
Hi All,

Bit of a newbie question i'm afraid, so sorry if this is a really
stupid question,

I am not sure if I am trying to do this in the right place as I am sure
SQL Server has a far better way of doing this

What I am trying to do is join the contents of several columns and
present the entry into a new column. the entries of all the columns I
am trying to join are different types such as dates and numbers. I want
to join all columns as a text string. To make it just a even more
tricky I wish to insert a # between all fields.

Just in case my poor description has got you thinking What the F*&K
here is an example of what I am trying to do

C1 C2 C3 C4 C5
Ian 1234 22/02/2006 123456789 Ian#1234#22/02/2006#1234567890
I have been trying to do this in the Formula in the design veiw of the
table.

Any Advice would be fantastic.

Many Thank

Ian

Monday, February 20, 2012

Join order considerations in SQL Server (2005)

I'm doing a bit of research on join order in terms of how it affects performance in SQL Server (specifically 2005).

Can someone point me to some sites that do a good job of explaining this, or, can you give me a good overview of the topic?

As far as performance goes, I think you will be fine regardless of your join order for the most part. In outer joins (think of a LEFT OUTER JOIN) the order of your tables will matter because the result set would be different depending on which table is the outer and which table is the inner. That is not so much a performance consideration as it is a results consideration.

One motto I always live by is to try it and see. So you can get a lot of replies with links, but I say look at the query plans (You can choose display estimated query plan or if you have a test system you can display the actual execution plan when the query finishes) and play with different join orders.

If you are relatively new to query plans there are a ton of great books. I would highly reccomend Itzik Ben Gan's Inside SQL Server: T-SQL Programming book for his treatment of this topic.

|||

Justin:

If you are wanting to enforce the join order and go rules based you need to SET FORCEPLAN ON; however, this is not something that should normally be practiced. Our standards here pretty much forbid this use of this setting.


Dave