Showing posts with label moving. Show all posts
Showing posts with label moving. Show all posts

Monday, March 19, 2012

Change data type during INSERT INTO ?

I'm doing a data conversion project, moving data from one SQL app to
another.
I'm using INSERT INTO with Select and have the syntax correct. But when
executing the script I get:

Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to float.

Is it possible to change the data type during the INSERT INTO statement?

ThanksThe destination table should be compatible with the data type of select
table

Madhivanan|||"rdraider" <rdraider@.sbcglobal.net> wrote in message
news:eRu_d.11608$C47.6368@.newssvr14.news.prodigy.c om...
> I'm doing a data conversion project, moving data from one SQL app to
> another.
> I'm using INSERT INTO with Select and have the syntax correct. But when
> executing the script I get:
> Server: Msg 8114, Level 16, State 5, Line 1
> Error converting data type varchar to float.
> Is it possible to change the data type during the INSERT INTO statement?
> Thanks

As the insert into has to guess about the datatypes of the table to create,
the safest way is to specifically create the table prior to the select into.

You can use cast or convert to gain a little more control over the way the
table is created.
but since you didn't post and example I can't help you more than this.|||On Fri, 18 Mar 2005 06:48:42 GMT, rdraider wrote:

>I'm doing a data conversion project, moving data from one SQL app to
>another.
>I'm using INSERT INTO with Select and have the syntax correct. But when
>executing the script I get:
>Server: Msg 8114, Level 16, State 5, Line 1
>Error converting data type varchar to float.
>Is it possible to change the data type during the INSERT INTO statement?

Hi rdraider,

If you use
INSERT INTO tablename (col1, col2, ..., colN)
SELECT expr1, expr2, ..., exprN
FROM ...
WHERE ...

Then the result of each expression will implicitly be converted to the
datatype of the corresponding column before it's stored in the table.

Your message indicates that one of your expressions is of datetype
varchar, but the corresponding column is of datatype float, and the
implicit conversion failed. E.g. because the varchar value to be
converted happened to be 'xxhasiu'.

If you use INSERT without column list, or SELECT *, then the first thing
should be to add a column list - changes to the table structure might
change the number and order of columns in the INSERT or in the SELECT *,
inducing a mismatch; explicitly naming the columns ensures that this
won't happen.

If that doesn't fix it, then find out which column(s) in the destination
table are of datatype float; run the SELECT (without the INSERT INTO) to
see the results and inspect the output to find the offending value. If
the output has too many rows for visual inspection, you might try adding
AND ISNUMERIC(exprN) = 0
This will return only the rows where exprN can't be converted to int,
float, money or decimal.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)

Sunday, March 11, 2012

Change Column Order

How does one go about changing the column order of the data moving thru an SSIS package? It'd be nice to able to do this at any point in the package for readability, but where I really need it is in the Flat File Output. I need to deliver the columns in a specific order, and I can't figure out how to do that.

This seems to be such a basic question, but I can't find it in Search anywhere. My apologies if it's already been answered.The column order of a flat file is defined within the connection. Changing column order within the pipeline itself would be a bad ideas as this require moving data around, which costs. A way to do this as a view for readability may well be nice, but may end up being confusing as well.

The default behaviour of the Flat File Destination means you create a new connection within the UI, and that connection will happily define the columns according to the buffer, which is just perfect 99% of the time. For your case you have two workarounds-

1 - Add your Flat File Connection, set file and delimiters. Select the Advanced tab, and add your columns as you want in the correct order. This connection can then be selected, and you map the columns. You could do this within the Flat File Destination, as this will create all columns to start with, but cannot change order, which is a shame, so you will have to remove and insert columns to get the correct order overall.

2 - A simple method is to create a flat file that represents what you want to produce from SSIS. Then you can add a new Flat File Connection, and select the sample file, and allow the columns to be generated from this file. You may still wish to fine tune this through the Advanced tab, but it should do the bulk of the work.

Why not log some Feedback on MSDN for the ability to change column order within the Flat File connection as that is really what you want I belive.|||I had the exact same question...and I too couldn't believe that it wasn't simple to re-order the outputs being written to a flat file.

I am pulling data from a database using a SQL Query then adding columns with the Derived Column transform. I want the derived columns to go at the beginning of the output file, not the end.

I like your idea of reverse engineering a sample file...I will give that a shot.

I am currently evaluating ETL tools for converting data from various database types and structures to complex (multiple record types) flat files. Overall, I am pretty impressed with SSIS although I have noticed that some tasks are not as straightforward as they are in Sagent and Informatica.

|||If you are not already aware there are a couple of whitepapers that may help your evaluation-

Microsoft SQL Server: Forrester Report: Microsoft Addresses Enterprise ETL
(http://www.microsoft.com/sql/technologies/integration/foresterreport.mspx)
Well that's one. The other was a review of SSIS compared to Informatica, by Conchango. I can't find it now in the wake of the site updates for RTM. Hopefully it will reappear or someone will post a link. Searching microsoft.com only gives a broken link.

Don't forget you get a free RDBMS, OLAP and Reporting System when you buy SSIS :)|||

Very funny...you never know when that RDBMS may come in handy ; )

Thanks for the Forrester link.

I found the Conchango review....thanks for the lead.
http://download.microsoft.com/download/1/0/3/103fd39e-3ca4-4db7-a087-1263dc6ed0b1/CompIntTools.pdf

Our enterprise product is built pretty much from front to back on Microsoft technology so SSIS will be hard to beat if it can get the job done efficiently.

Thursday, February 16, 2012

Caught in a Replication Catch-22, SQLServer2005

I am currently moving from SQL2K to 2005 and am having trouble incorporating
replication in 2005.
First off, I've found myself in a loop where I have two publications that
"don't exist" even though they show up in my Local Publishers list. I can't
delete tables that are articles in those publications because the tables are
being replicated. However, if I try to delete the publication, I get the
message that the publication doesn't exist. So the tables I need to drop are
bound to a publication that doesn't exist.
I've tried looking in the distribution and master databases to find the
missing links but I can't find anything. Without spending a lot of time
going through how I got in this mess, I'd just like to know if there are some
sp's that I can use to purge these publications once and for all.
Thanks in advance.
Roger.
You don't say which type of replication you are using. My experience
is only with merge replication, in this case I would suggest using
sp_removedbreplication in addition to normal sp_dropmergepublication
(or delete from the Gui)
Please see KB324401 for recommendations from MS. http://
support.microsoft.com/kb/324401
Tim Hill
On Feb 9, 3:33 pm, Roger Denison
<RogerDeni...@.discussions.microsoft.com> wrote:
> I am currently moving from SQL2K to 2005 and am having trouble incorporating
> replication in 2005.
> First off, I've found myself in a loop where I have two publications that
> "don't exist" even though they show up in my Local Publishers list. I can't
> delete tables that are articles in those publications because the tables are
> being replicated. However, if I try to delete the publication, I get the
> message that the publication doesn't exist. So the tables I need to drop are
> bound to a publication that doesn't exist.
> I've tried looking in the distribution and master databases to find the
> missing links but I can't find anything. Without spending a lot of time
> going through how I got in this mess, I'd just like to know if there are some
> sp's that I can use to purge these publications once and for all.
> Thanks in advance.
> --
> Roger.
|||I had a similar problem to this. The only way round it was to script
the publications & subscriptions, remove replication and then
re-enable.
On Fri, 9 Feb 2007 07:33:00 -0800, Roger Denison
<RogerDenison@.discussions.microsoft.com> wrote:

>I am currently moving from SQL2K to 2005 and am having trouble incorporating
>replication in 2005.
>First off, I've found myself in a loop where I have two publications that
>"don't exist" even though they show up in my Local Publishers list. I can't
>delete tables that are articles in those publications because the tables are
>being replicated. However, if I try to delete the publication, I get the
>message that the publication doesn't exist. So the tables I need to drop are
>bound to a publication that doesn't exist.
>I've tried looking in the distribution and master databases to find the
>missing links but I can't find anything. Without spending a lot of time
>going through how I got in this mess, I'd just like to know if there are some
>sp's that I can use to purge these publications once and for all.
>Thanks in advance.

Friday, February 10, 2012

CASS Certification and Postal Discounts

My organization is moving to a SQL based CRM solution that is customized for
our industry. As a part of this move we are converting all our documents
over to SQL Reports. We have also been contemplating using a CASS certified
product to help us get some substantial postal discounts for our mailings.
Is anyone aware of a product that can take the data being fed into a
reporting server and queue the reports, sort and certify, and then print to
allow postal discounts?
I realize that I am simplifing the process some but I am trying to find out
if there are any vendors servicing this market yet.
--
"Okay, I signed in this box. How do I wipe the ink off my screen now?"I don't know of a product that will do what you want...
However, you might think of this in two parts..
Certifying the addresses in the database,
sorting/printing/printing the CASS Cert documents
The first will be much easier than the second...
In order to get the lowest rate you must print the documents in the same
group together... Docs will print in the order that they complete, so you'd
probably have to buy/write something to group reports into a single printing
batch..
Another thing you might try is to print each group of reports one at a time,
don't start the second group until the first has completed...
In any case - you'll probably have to work very hard if each report is
specific to the address, instead of printing the same report and delivering
it to many people.
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.
"Julian I. Spring" wrote:
> My organization is moving to a SQL based CRM solution that is customized for
> our industry. As a part of this move we are converting all our documents
> over to SQL Reports. We have also been contemplating using a CASS certified
> product to help us get some substantial postal discounts for our mailings.
> Is anyone aware of a product that can take the data being fed into a
> reporting server and queue the reports, sort and certify, and then print to
> allow postal discounts?
> I realize that I am simplifing the process some but I am trying to find out
> if there are any vendors servicing this market yet.
> --
> "Okay, I signed in this box. How do I wipe the ink off my screen now?"