显示标签为“second”的博文。显示所有博文
显示标签为“second”的博文。显示所有博文

2012年3月29日星期四

bcp_moretext & NULLs

When sending two 'text' columns using BCP, and using bcp_moretext because
the first is very large, and if the second is NULL, then how do you send a
NULL value using bcp_moretext?Peter (schmidt.peter@.comcast.net) writes:
> When sending two 'text' columns using BCP, and using bcp_moretext because
> the first is very large, and if the second is NULL, then how do you send a
> NULL value using bcp_moretext?

I have never used bcp_moretext, but what happens it you set the length to 0
with bcp_collen?

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

2012年2月23日星期四

BCP : Format File : Second Question

Before answering this question please read my previous post 10 minutes ago.
Assuming that I have to use a Format File with bcp to export a table that
has a column I don't want exported.
What Format File should I create in order to achive the following two goals:
I wish to create the smallest data file possible, and would be the fastest
for the server to process in both directions (out/in).
Can you provide the syntax to generate the format file?
Thanks
Russell Mangel
Las Vegas, NVRussell Mangel,
Check arguments -n and -N in BOL.
AMB
"Russell Mangel" wrote:

> Before answering this question please read my previous post 10 minutes ago
.
> Assuming that I have to use a Format File with bcp to export a table that
> has a column I don't want exported.
> What Format File should I create in order to achive the following two goal
s:
> I wish to create the smallest data file possible, and would be the fastest
> for the server to process in both directions (out/in).
> Can you provide the syntax to generate the format file?
> Thanks
> Russell Mangel
> Las Vegas, NV
>
>|||Yeah, I made some tests.
The database I have, does not have any UniCode columns, and so when I export
using -n the data does get much smaller.
However, since I am transferring the data via FTP, I ran PKZIP on the data
files and discovered that it does a great job of compressing UniCode, so it
turns I will use -N switch anyway.
Thanks Again.
Russell Mangel
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:BFF9DF60-13D3-48CC-A7FA-979B23DA0BD4@.microsoft.com...
> Russell Mangel,
> Check arguments -n and -N in BOL.
>
> AMB
>
> "Russell Mangel" wrote:
>|||Russell Mangel (russell@.tymer.net) writes:
> Before answering this question please read my previous post 10 minutes
> ago.
> Assuming that I have to use a Format File with bcp to export a table that
> has a column I don't want exported.
> What Format File should I create in order to achive the following two
> goals:
> I wish to create the smallest data file possible, and would be the fastest
> for the server to process in both directions (out/in).
> Can you provide the syntax to generate the format file?
No, not without the table definition.
The fast format is native format, which means that you need to describe
each column correctly. This is a little more tricky that describing a
character format. Then again, anything goes, so if you have a mix of
native and charcter format that is not much of a distaster.
You will probably find it easier to use a view together as I suggested in my
other post together with the -n or -N option as suggested by Alejandro.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||[posted and mailed]
Erland Sommarskog (esquel@.sommarskog.se) writes:
> Russell Mangel (russell@.tymer.net) writes:
> No, not without the table definition.
I spoke to soon! I forgot about the format option. You can do this:
bcp Northwind..Orders format dummy.txt -f Orders.fmt -N -T
This generates a format file for you for native format. Then you can edit
the format file to exclude the column you don't want to include. No need
for view or queryout.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

2012年2月9日星期四

Basic select statement question

If I want to select certain values from a table where date is equal to something and the second field is null,would I go.

select * from table where date = 'something' and Sent = null or something else because if I do it this way I get nothing as a result but if I scroll down I can see that I have null values.

thanksNULL is a tricky beast, because nothing ever equals NULL, not even NULL itself. You need to modify your statement slightly to use a semantically different test, like:SELECT *
FROM table
WHERE date = 'something'
AND Sent IS nullThis seems like a trivial difference, and from a coding perspective it is. From the logical perspective however, the difference is huge.

-PatP|||Ooh,that made all the difference, I always say, it is easy once you know how to do it.
Thanks for you help once again|||Since you're dealing with this, you might want to look up ANSI_NULLS in Book Online and memorize it. :) It will save you a lot of pain down the road. Make sure you use SET ANSI_NULLS ON when creating tables and procedures.|||Will do so,thanks