[dba-SQLServer] Diving off the deep end

Paul Nielsen pauln at sqlserverbible.com
Thu Mar 20 11:29:39 CDT 2008


You can strip, concatenate, and update all in one query


IN the airline reservation system, in one query I pivoted the 200 incoming
comma delimited flights into a table using a UDF, left joined with the
existing flight cache, parsed the flight data, calculated the number of legs
in the flight and inserted the result into a table variable. 

In SQL Server it's generally better to do as much as possible in as few
set-based operations as possible. 

-Paul 




-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Thursday, March 20, 2008 10:14 AM
To: 'Discussion concerning MS SQL Server'
Subject: Re: [dba-SQLServer] Diving off the deep end

I'm getting there.  I now have a query running stripping the leading zeros
from three fields that I will then need to append together to get a single
address field.

So much of this stuff is easy enough if you do it all the time.  My problem
is that I am just spread too thin. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Paul
Nielsen
Sent: Thursday, March 20, 2008 11:51 AM
To: 'Discussion concerning MS SQL Server'
Subject: Re: [dba-SQLServer] Diving off the deep end

Just to clarify, 

if the statement accesses a data source (has a from clause) use select, 

if not use set. 

-Paul 


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Fuller
Sent: Thursday, March 20, 2008 8:05 AM
To: Discussion concerning MS SQL Server
Subject: Re: [dba-SQLServer] Diving off the deep end

When assigning to a variable you must begin the statement with either SET
@VAR = 'ABC' or SELECT @var = 'abc'.

A.
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com


__________ NOD32 2963 (20080320) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com


__________ NOD32 2963 (20080320) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com





More information about the dba-SQLServer mailing list