Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Thursday, March 29, 2012

Converting DataType=TEXT to DataType=STR

SadHi,

I have an input text file which contains line(s) which can have more than 8000 characters.

I am able to read the lines in this file by specifying that the input column is data type = Text Stream [DT_TEXT] and I can then write the lines to another text file.

But, what I want to do is to use only the right-most 8000 characters. When I try to convert the input column to data type = String [DT_STR] using the Data Conversion transformation then I get the error:-

The conversion returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.

I cannot use the string manipulation functions e.g. RIGHT or SUBSTRING in a Derived Column transformation because these functions do not work with DT_TEXT data.
Any Ideas?!

Thanks.SadYou'd only need *1* line of custom code in a Script component transformation to extract your rightmost 8000 characters before moving on to the data type conversion.

-Doug|||Thanks Doug ... Did you mean a Script Component which looks something like:-

Public Class ScriptMain

Inherits UserComponent

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim ascii As Text.Encoding

Dim asciiChars(10) As Char

ascii.GetChars(Row.InputColumn.GetBlobData(1, 1), 0, 1, asciiChars, 0)

Dim asciiString As New String(asciiChars)

MsgBox(asciiString)

End Sub

End Class

When I run the package it fails at the ascii.getchars line with the following error message:-

Error: 0xC0047062 at Data Flow Task, Script Component [106]: System.NullReferenceException: Object reference not set to an instance of an object.

All I am trying to do is extract the first byte and convert it to an ascii char (before I go on to work out the lengths to extract the right-most 8000 chars etc.)

Is this what you had in mind? Or, is there another way to do it?

Many Thanks.

|||This should do what you want. You will need to import System.Text.Encoding.



Dim Start As Integer = Max(0, CInt(Row.InputColumn.Length) - 8001)
Dim Length As Integer = Min(8000, CInt(Row.InputColumn.Length))
Dim asciiString As String = ASCII.GetString(Row.InputColumn.GetBlobData(Start, Length)


|||Just to confirm that Jay's suggestion works. Many Thanks.sqlsql

Tuesday, March 27, 2012

Converting Data from SqlServer Express to SqlServer 2005 beta 2??

Hi,
Was wondering if anyone could tell me how to convert the an SQL Server
Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a day
or so now and can't seem to find how to do this!!!
Any ideas?
Many Thanks
Wayne Gibson
Hi
Detach the DB in Express and attach it in SQL Server 2005. Or Backup and
Restore.
The backup and data files have 100% the same format.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Wayne Gibson" <wayne.gibson@.rendersoft.com> wrote in message
news:d9gca4$t42$1$8300dec7@.news.demon.co.uk...
> Hi,
> Was wondering if anyone could tell me how to convert the an SQL Server
> Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a
> day or so now and can't seem to find how to do this!!!
> Any ideas?
> Many Thanks
> Wayne Gibson
>
|||You should find you can just attach it with sp_attach_db. Did you try
that?
Please ask SQL Server 2005 questions in the appropriate newsgroups:
http://communities.microsoft.com/new...=sqlserver2005
David Portas
SQL Server MVP
|||Hi Mike,
Thanks for responding..
Could you tell me how I go about making a backup of a MS SQLServer Express
file.
I got MS SQLServer Express as part of the Visual Studio 2005 Beta 2, but
can't see any tools apart from those in the IDE.
Thanks
Wayne

Converting Data from SqlServer Express to SqlServer 2005 beta 2??

Hi,
Was wondering if anyone could tell me how to convert the an SQL Server
Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a day
or so now and can't seem to find how to do this!!!
Any ideas?
Many Thanks
Wayne Gibson
Hi
Detach the DB in Express and attach it in SQL Server 2005. Or Backup and
Restore.
The backup and data files have 100% the same format.
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Wayne Gibson" <wayne.gibson@.rendersoft.com> wrote in message
news:d9gca4$t42$1$8300dec7@.news.demon.co.uk...
> Hi,
> Was wondering if anyone could tell me how to convert the an SQL Server
> Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a
> day or so now and can't seem to find how to do this!!!
> Any ideas?
> Many Thanks
> Wayne Gibson
>
|||You should find you can just attach it with sp_attach_db. Did you try
that?
Please ask SQL Server 2005 questions in the appropriate newsgroups:
http://communities.microsoft.com/new...=sqlserver2005
David Portas
SQL Server MVP
|||Hi Mike,
Thanks for responding..
Could you tell me how I go about making a backup of a MS SQLServer Express
file.
I got MS SQLServer Express as part of the Visual Studio 2005 Beta 2, but
can't see any tools apart from those in the IDE.
Thanks
Wayne

Converting Data from SqlServer Express to SqlServer 2005 beta 2??

Hi,
Was wondering if anyone could tell me how to convert the an SQL Server
Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a day
or so now and can't seem to find how to do this!!!
Any ideas?
Many Thanks
Wayne GibsonYou should find you can just attach it with sp_attach_db. Did you try
that?
Please ask SQL Server 2005 questions in the appropriate newsgroups:
http://communities.microsoft.com/newsgroups/default.asp?icp=sqlserver2005
--
David Portas
SQL Server MVP
--|||Hi
Detach the DB in Express and attach it in SQL Server 2005. Or Backup and
Restore.
The backup and data files have 100% the same format.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Wayne Gibson" <wayne.gibson@.rendersoft.com> wrote in message
news:d9gca4$t42$1$8300dec7@.news.demon.co.uk...
> Hi,
> Was wondering if anyone could tell me how to convert the an SQL Server
> Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a
> day or so now and can't seem to find how to do this!!!
> Any ideas?
> Many Thanks
> Wayne Gibson
>|||Hi Mike,
Thanks for responding..
Could you tell me how I go about making a backup of a MS SQLServer Express
file.
I got MS SQLServer Express as part of the Visual Studio 2005 Beta 2, but
can't see any tools apart from those in the IDE.
Thanks
Wayne

Converting Data from SqlServer Express to SqlServer 2005 beta 2??

Hi,
Was wondering if anyone could tell me how to convert the an SQL Server
Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a day
or so now and can't seem to find how to do this!!!
Any ideas?
Many Thanks
Wayne GibsonHi
Detach the DB in Express and attach it in SQL Server 2005. Or Backup and
Restore.
The backup and data files have 100% the same format.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Wayne Gibson" <wayne.gibson@.rendersoft.com> wrote in message
news:d9gca4$t42$1$8300dec7@.news.demon.co.uk...
> Hi,
> Was wondering if anyone could tell me how to convert the an SQL Server
> Express (MDF) file into SQL Server 2005 Beta 2. I've been looking for a
> day or so now and can't seem to find how to do this!!!
> Any ideas?
> Many Thanks
> Wayne Gibson
>|||You should find you can just attach it with sp_attach_db. Did you try
that?
Please ask SQL Server 2005 questions in the appropriate newsgroups:
http://communities.microsoft.com/ne...p=sqlserver2005
David Portas
SQL Server MVP
--|||Hi Mike,
Thanks for responding..
Could you tell me how I go about making a backup of a MS SQLServer Express
file.
I got MS SQLServer Express as part of the Visual Studio 2005 Beta 2, but
can't see any tools apart from those in the IDE.
Thanks
Waynesqlsql

Converting Crystal Reports

Hi,
I am working on converting Crystal Reports to RDL files. I want to convert
my reports to an RDL file, so I can use Reporting Services in MS SQL and
Visual Studio.Net- instead of Crystal. I have two questions:
I have done a lot of research into this and it seems there are paid services
such as Hitachi consulting that will do this and http://www.rpttosql.com.
However, my company is not willing to pay for such services. So what I have
done, is convert the Crystal Report to XML using Crystal 9.
1. Now I want to convert that XML file to an RDL file? How can I do this?
Any direct links or methods will be very helpful.
2. Also, is their an online utility that will do this? Any direct links
will be very helpful.
I have downloaded a program that can convert the Crystal Reports to XML.
However, Crystal 9 can do the same. I am still at the same situation in
question one- I can't convert the XML file to an RDL. Advise is kindly
requested.
Thanks,
RickAn RDL file is an xml file bases on the schema for rdl (which most likely
stands for report definition language, just a guess). To see what it looks
like create a simple report. Then go View, Code. What you see is the XML
file. The schema for it is at the top:
http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition
If you compare the xml from Crystal you will see that they are nothing
alike. Now Crystal has similar concepts so for some things there might be a
one to one correspondence but not for everything. It is a non-trivial task
to convert (hence why Hitachi is charging for it).
Most people doing this have the Crystal report up and then copy and paste
things like text, the query definition etc.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"jjrr007" <jjrr007@.discussions.microsoft.com> wrote in message
news:A62BF888-87FF-4E64-98D3-B8E540AB7D52@.microsoft.com...
> Hi,
> I am working on converting Crystal Reports to RDL files. I want to
convert
> my reports to an RDL file, so I can use Reporting Services in MS SQL and
> Visual Studio.Net- instead of Crystal. I have two questions:
> I have done a lot of research into this and it seems there are paid
services
> such as Hitachi consulting that will do this and http://www.rpttosql.com.
> However, my company is not willing to pay for such services. So what I
have
> done, is convert the Crystal Report to XML using Crystal 9.
> 1. Now I want to convert that XML file to an RDL file? How can I do this?
> Any direct links or methods will be very helpful.
> 2. Also, is their an online utility that will do this? Any direct links
> will be very helpful.
> I have downloaded a program that can convert the Crystal Reports to XML.
> However, Crystal 9 can do the same. I am still at the same situation in
> question one- I can't convert the XML file to an RDL. Advise is kindly
> requested.
> Thanks,
> Rick
>|||In addition to Bruces response, I had heard that Hitachi folks made a
conversion tool that their Consultants use to do this quickly...
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> wrote in message
news:OYbTXZhDFHA.936@.TK2MSFTNGP12.phx.gbl...
> An RDL file is an xml file bases on the schema for rdl (which most likely
> stands for report definition language, just a guess). To see what it looks
> like create a simple report. Then go View, Code. What you see is the XML
> file. The schema for it is at the top:
> http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition
> If you compare the xml from Crystal you will see that they are nothing
> alike. Now Crystal has similar concepts so for some things there might be
> a
> one to one correspondence but not for everything. It is a non-trivial task
> to convert (hence why Hitachi is charging for it).
> Most people doing this have the Crystal report up and then copy and paste
> things like text, the query definition etc.
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "jjrr007" <jjrr007@.discussions.microsoft.com> wrote in message
> news:A62BF888-87FF-4E64-98D3-B8E540AB7D52@.microsoft.com...
>> Hi,
>> I am working on converting Crystal Reports to RDL files. I want to
> convert
>> my reports to an RDL file, so I can use Reporting Services in MS SQL and
>> Visual Studio.Net- instead of Crystal. I have two questions:
>> I have done a lot of research into this and it seems there are paid
> services
>> such as Hitachi consulting that will do this and http://www.rpttosql.com.
>> However, my company is not willing to pay for such services. So what I
> have
>> done, is convert the Crystal Report to XML using Crystal 9.
>> 1. Now I want to convert that XML file to an RDL file? How can I do
>> this?
>> Any direct links or methods will be very helpful.
>> 2. Also, is their an online utility that will do this? Any direct links
>> will be very helpful.
>> I have downloaded a program that can convert the Crystal Reports to XML.
>> However, Crystal 9 can do the same. I am still at the same situation in
>> question one- I can't convert the XML file to an RDL. Advise is kindly
>> requested.
>> Thanks,
>> Rick
>|||You can generate your RDL/XML files programmatically w/o XML or VS, using the
RDL reader/writer:
http://www.rdlcomponents.com
Thanks
Jerry
"Wayne Snyder" wrote:
> In addition to Bruces response, I had heard that Hitachi folks made a
> conversion tool that their Consultants use to do this quickly...
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> wrote in message
> news:OYbTXZhDFHA.936@.TK2MSFTNGP12.phx.gbl...
> > An RDL file is an xml file bases on the schema for rdl (which most likely
> > stands for report definition language, just a guess). To see what it looks
> > like create a simple report. Then go View, Code. What you see is the XML
> > file. The schema for it is at the top:
> > http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition
> >
> > If you compare the xml from Crystal you will see that they are nothing
> > alike. Now Crystal has similar concepts so for some things there might be
> > a
> > one to one correspondence but not for everything. It is a non-trivial task
> > to convert (hence why Hitachi is charging for it).
> >
> > Most people doing this have the Crystal report up and then copy and paste
> > things like text, the query definition etc.
> >
> > --
> > Bruce Loehle-Conger
> > MVP SQL Server Reporting Services
> >
> > "jjrr007" <jjrr007@.discussions.microsoft.com> wrote in message
> > news:A62BF888-87FF-4E64-98D3-B8E540AB7D52@.microsoft.com...
> >> Hi,
> >>
> >> I am working on converting Crystal Reports to RDL files. I want to
> > convert
> >> my reports to an RDL file, so I can use Reporting Services in MS SQL and
> >> Visual Studio.Net- instead of Crystal. I have two questions:
> >>
> >> I have done a lot of research into this and it seems there are paid
> > services
> >> such as Hitachi consulting that will do this and http://www.rpttosql.com.
> >> However, my company is not willing to pay for such services. So what I
> > have
> >> done, is convert the Crystal Report to XML using Crystal 9.
> >>
> >> 1. Now I want to convert that XML file to an RDL file? How can I do
> >> this?
> >> Any direct links or methods will be very helpful.
> >>
> >> 2. Also, is their an online utility that will do this? Any direct links
> >> will be very helpful.
> >>
> >> I have downloaded a program that can convert the Crystal Reports to XML.
> >> However, Crystal 9 can do the same. I am still at the same situation in
> >> question one- I can't convert the XML file to an RDL. Advise is kindly
> >> requested.
> >>
> >> Thanks,
> >> Rick
> >>
> >
> >
>
>

Thursday, March 22, 2012

Converting a parent-child table into a genrational table / text file

I need to convert a parent - child table into another table or a text file containing in a generational format.

eg.

child / parent / grand parent / great grand parent / ....

Does anyone have a stored procedure of code to do this?

I'm working with a dimension having 250,000 + members, writing code is fast enough for much smaller hierarchies but with a dimension this size we need something fast.

Thank you

Hi Rod,

Not sure if this is the same problem as you posted in TSQL under "Adjacency List' - as suggested there, recursive CTE would be one approach in SQL Server 2005:

>>

with GenTable(LeafKey, LeafName, GenNum, AncestorKey, AncestorName) as

(select do.OrganizationKey as LeafKey, do.OrganizationName as LeafName,

1 as GenNum, do1.OrganizationKey as AncestorKey,

do1.OrganizationName as AncestorName

from dbo.DimOrganization do

join dbo.DimOrganization do1

on do.ParentOrganizationKey = do1.OrganizationKey

where not exists(select *

from dbo.DimOrganization do2

where do2.ParentOrganizationKey = do.OrganizationKey)

union all

select gt.LeafKey, gt.LeafName,

gt.GenNum + 1 as GenNum, do.ParentOrganizationKey as AncestorKey,

do1.OrganizationName as AncestorName

from GenTable gt

join dbo.DimOrganization do

on gt.AncestorKey = do.OrganizationKey

join dbo.DimOrganization do1

on do.ParentOrganizationKey = do1.OrganizationKey)

select LeafKey, [1] as Gen1Key, [2] as Gen2Key, [3] as Gen3Key

from (select LeafKey, GenNum, AncestorKey

from GenTable) gt

Pivot (Max(AncestorKey)

for GenNum in ([1], [2], [3])) as pt

order by LeafKey

--

3 14 2 1
4 14 2 1
5 14 2 1
6 14 2 1
7 14 2 1
8 2 1 NULL
11 9 1 NULL
12 9 1 NULL
13 10 1 NULL

>>

|||Hi Deepak,

Thank you very much, it's been as long day and I'll look closer in the morning. It looks vey helpful. I should of mentioned that I have to do the with 2000 and 2005 but this likes I'm half way there and on the right track

Thanks again,

Rod

Converting a file into multiple tables

This file format has multiple levels (X12).
One level could have one or more instances of the
next level contained within it. Kind of like XML,
except that some sections have no end tags, and the
ones that do have end tags actually have a _different_
tag for the end. (ISA ...IEA or GS ... GE)

It's easy enough to read a line at a time, see what
type it is, and insert its parts into the appropriate
table. Keeping track of the keys of the parent level
for relationships.

But I'm wandering whether there's some (not impossibly
complex) more efficient method with SQL and/or DTS.

--
Wes Groleau

If you put garbage in a computer nothing comes out but garbage.
But this garbage, having passed through a very expensive machine,
is somehow ennobled and none dare criticize it.Take a look at SQLXML Bulk Load
(http://msdn2.microsoft.com/en-us/library/ms171993.aspx).

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Wes Groleau" <groleau+news@.freeshell.orgwrote in message
news:K7x6h.10720$l%2.2462@.trnddc05...

Quote:

Originally Posted by

This file format has multiple levels (X12).
One level could have one or more instances of the
next level contained within it. Kind of like XML,
except that some sections have no end tags, and the
ones that do have end tags actually have a _different_
tag for the end. (ISA ...IEA or GS ... GE)
>
It's easy enough to read a line at a time, see what
type it is, and insert its parts into the appropriate
table. Keeping track of the keys of the parent level
for relationships.
>
But I'm wandering whether there's some (not impossibly
complex) more efficient method with SQL and/or DTS.
>
--
Wes Groleau
>
If you put garbage in a computer nothing comes out but garbage.
But this garbage, having passed through a very expensive machine,
is somehow ennobled and none dare criticize it.

|||Dan Guzman wrote:

Quote:

Originally Posted by

Take a look at SQLXML Bulk Load
(http://msdn2.microsoft.com/en-us/library/ms171993.aspx).


He'd also need an EDI to XML translator. (I recognize those
damnable start/end tags.) Google indicates that several
translators exist; anyone want to offer a recommendation?|||You're right about the EDI to XML translator - I misread Wes's post. of
course, SQLXML can't consume EDI directly.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Ed Murphy" <emurphy42@.socal.rr.comwrote in message
news:PCH6h.708$Fg.683@.tornado.socal.rr.com...

Quote:

Originally Posted by

Dan Guzman wrote:
>

Quote:

Originally Posted by

>Take a look at SQLXML Bulk Load
>(http://msdn2.microsoft.com/en-us/library/ms171993.aspx).


>
He'd also need an EDI to XML translator. (I recognize those
damnable start/end tags.) Google indicates that several
translators exist; anyone want to offer a recommendation?

|||Dan Guzman wrote:

Quote:

Originally Posted by

You're right about the EDI to XML translator - I misread Wes's post. of
course, SQLXML can't consume EDI directly.


Of course, I could easily write something to
convert it to XML that SQL server can read.
But then I could just as easily convert it
directly into INSERT statements. I'm just
wondering whether DTS or anything else is faster.

I already have a tool that loads the entire
file into an array of lines and provides various
query functions for other apps to access it.

But I'd like to put multiple files in the database
instead of having to select one file at a time.

By the way, whatever the technique is, it could
probably also handle GEDCOM files.

--
Wes Groleau

There ain't no right wing,
there ain't no left wing.
There's only you and me and we just disagree.
(apologies to Jim Krueger)|||Ed Murphy wrote:

Quote:

Originally Posted by

Dan Guzman wrote:

Quote:

Originally Posted by

>Take a look at SQLXML Bulk Load
>(http://msdn2.microsoft.com/en-us/library/ms171993.aspx).


>
He'd also need an EDI to XML translator. (I recognize those
damnable start/end tags.) Google indicates that several
translators exist; anyone want to offer a recommendation?


I think I figured out a solution (haven't tried it yet).

Comments on this idea welcome (I'm kind of new to SQL):

The X12 files and GEDCOM files (maybe HL7, too?) have
multiple levels. Generally, each "level X" record
may own more than one record on level X+1

So if a file has (data elem delims changed to spaces)
....
CLP A B C
SVC X Y Z
SVC 1 2 3
CLP D E F
SVC P Q R
SVC 5 6 7
....
then the first pass through the file could create rows

.... A B C X Y Z ...
.... A B C 1 2 3 ...
.... D E F P Q R ...
.... D E F 5 6 7 ...

Next, one query could SELECT DISTINCT to give

.... A B C
.... D E F

while another could SELECT for

.... A X Y Z ...
.... A 1 2 3 ...
.... D P Q R ...
.... D 5 6 7 ...

and the same strategy could be used on each adjacent pair of levels.

Right ?

--
Wes Groleau

He that is good for making excuses, is seldom good for anything else.
-- Benjamin Franklin|||It's true that you can transform EDI and GEDCOM files directly into
relational format. I think the reason XML is commonly used as an
intermediate format is that XML is perfect for hierarchical data and you can
leverage a high-performance XML import utility like SQLXML without writing
additional code. Although it will take a while, I expect XML will
eventually replace both EDI and GEDCOM formats. You'll be a step ahead if
you can process XML too.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"Wes Groleau" <groleau+news@.freeshell.orgwrote in message
news:uJv7h.211$9e.25@.trnddc02...

Quote:

Originally Posted by

Ed Murphy wrote:

Quote:

Originally Posted by

>Dan Guzman wrote:

Quote:

Originally Posted by

>>Take a look at SQLXML Bulk Load
>>(http://msdn2.microsoft.com/en-us/library/ms171993.aspx).


>>
>He'd also need an EDI to XML translator. (I recognize those
>damnable start/end tags.) Google indicates that several
>translators exist; anyone want to offer a recommendation?


>
I think I figured out a solution (haven't tried it yet).
>
Comments on this idea welcome (I'm kind of new to SQL):
>
The X12 files and GEDCOM files (maybe HL7, too?) have
multiple levels. Generally, each "level X" record
may own more than one record on level X+1
>
So if a file has (data elem delims changed to spaces)
...
CLP A B C
SVC X Y Z
SVC 1 2 3
CLP D E F
SVC P Q R
SVC 5 6 7
...
then the first pass through the file could create rows
>
... A B C X Y Z ...
... A B C 1 2 3 ...
... D E F P Q R ...
... D E F 5 6 7 ...
>
Next, one query could SELECT DISTINCT to give
>
... A B C
... D E F
>
while another could SELECT for
>
... A X Y Z ...
... A 1 2 3 ...
... D P Q R ...
... D 5 6 7 ...
>
and the same strategy could be used on each adjacent pair of levels.
>
Right ?
>
--
Wes Groleau
>
He that is good for making excuses, is seldom good for anything else.
-- Benjamin Franklin

|||Dan Guzman wrote:

Quote:

Originally Posted by

It's true that you can transform EDI and GEDCOM files directly into
relational format. I think the reason XML is commonly used as an
intermediate format is that XML is perfect for hierarchical data and you
can leverage a high-performance XML import utility like SQLXML without
writing additional code. Although it will take a while, I expect XML
will eventually replace both EDI and GEDCOM formats. You'll be a step
ahead if you can process XML too.


OK, I do know how to read and write XML. But can an XML file
be formatted so that the utility will create multiple tables
with the appropriate foreign keys to relate them?

I got the impression when I was reading about it that one
XML file makes one table and vice versa.

--
Wes Groleau
----

"Thinking I'm dumb gives people something to
feel smug about. Why should I disillusion them?"
-- Charles Wallace
(in _A_Wrinkle_In_Time_)|||Wes Groleau wrote:

Quote:

Originally Posted by

OK, I do know how to read and write XML. But can an XML file
be formatted so that the utility will create multiple tables
with the appropriate foreign keys to relate them?
>
I got the impression when I was reading about it that one
XML file makes one table and vice versa.


The impression was wrong. I studied the MS KB article cited
earlier, and I can easily make such XML files. Only, the process
of transforming the file into XML is similar to the process used
by bulk load to turn the XML into records. So I suspect it would
add a little speed if I went directly to records.

--
Wes Groleau

Words of the Wild Wes(t) = http://ideas.lang-learn.us/WWWsqlsql

converting a databases transaction log into a human readable file

SQL SERVER 2000
Hello All,
Is there a method for converting a databases transaction log into a human
readable file (SQL) for the purposes of conducting an audit or debugging a
particular set of circumstances?
Thanks in advance
Russell J Morgan
Hi
You need to buy 3rd party tools to do this
www.logpi.com and http://www.lumigent.com
Regards
Mike
"Russell J Morgan" wrote:

> SQL SERVER 2000
> Hello All,
> Is there a method for converting a databases transaction log into a human
> readable file (SQL) for the purposes of conducting an audit or debugging a
> particular set of circumstances?
> Thanks in advance
> Russell J Morgan
>
>

converting a databases transaction log into a human readable file

SQL SERVER 2000
Hello All,
Is there a method for converting a databases transaction log into a human
readable file (SQL) for the purposes of conducting an audit or debugging a
particular set of circumstances?
Thanks in advance
Russell J MorganHi
You need to buy 3rd party tools to do this
www.logpi.com and http://www.lumigent.com
Regards
Mike
"Russell J Morgan" wrote:

> SQL SERVER 2000
> Hello All,
> Is there a method for converting a databases transaction log into a human
> readable file (SQL) for the purposes of conducting an audit or debugging a
> particular set of circumstances?
> Thanks in advance
> Russell J Morgan
>
>

converting a databases transaction log into a human readable file

SQL SERVER 2000
Hello All,
Is there a method for converting a databases transaction log into a human
readable file (SQL) for the purposes of conducting an audit or debugging a
particular set of circumstances?
Thanks in advance
Russell J MorganHi
You need to buy 3rd party tools to do this
www.logpi.com and http://www.lumigent.com
Regards
Mike
"Russell J Morgan" wrote:
> SQL SERVER 2000
> Hello All,
> Is there a method for converting a databases transaction log into a human
> readable file (SQL) for the purposes of conducting an audit or debugging a
> particular set of circumstances?
> Thanks in advance
> Russell J Morgan
>
>sqlsql

Converting .dbf to sql server table...batch file? command line?

My client will be receiving a .dbf file which needs to be uploaded
into a sql server database table (as an append) every week. They are
NOT computer savvy and I would like to automate this process rather
than go into enterprise manager and run data transformation.

Is there any way to write a batch file or a set of command lines which
will do this?

Thanks.

Monicamonica@.datashark.net (Monica J. Braverman) wrote in message news:<d70cd025.0310081033.375fbc9b@.posting.google.com>...
> My client will be receiving a .dbf file which needs to be uploaded
> into a sql server database table (as an append) every week. They are
> NOT computer savvy and I would like to automate this process rather
> than go into enterprise manager and run data transformation.
> Is there any way to write a batch file or a set of command lines which
> will do this?
> Thanks.
> Monica
DTS package would probably be the easiest solution. Create the package
as an import from the .dbf into the approriate table and then run it
with each new .dbf received. If running DTS packages is a bit
'complex' for your users you could wrap it up in an applicaion/wizard
(eg in VB) and execute it that way.|||monica@.datashark.net (Monica J. Braverman) wrote:
>My client will be receiving a .dbf file which needs to be uploaded
>into a sql server database table (as an append) every week. They are
>NOT computer savvy and I would like to automate this process rather
>than go into enterprise manager and run data transformation.
>Is there any way to write a batch file or a set of command lines which
>will do this?

You might create a DTS package on the server, then create a batch file
to access it that calls the DTSRUN.exe program. I have a batch file
with this as the command line:
dtsrun /e /n"dtspackagename" /sSQLServerName and it works very well.
hth,
Myron|||Hi,
you can automate your process using a command prompt utility named
"bcp"; if you try to execute this command you get the syntax:

C:\>bcp
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide
character type]
[-N keep non-text native] [-V file format version] [-q quoted
identifier]
[-C code page specifier] [-t field terminator] [-r row
terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional
enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]

Another way is to use the T-SQL command "BULK INSERT".
You can find explanations on your MS-SQL documentation.

Bye.

monica@.datashark.net (Monica J. Braverman) wrote in message news:<d70cd025.0310081033.375fbc9b@.posting.google.com>...
> My client will be receiving a .dbf file which needs to be uploaded
> into a sql server database table (as an append) every week. They are
> NOT computer savvy and I would like to automate this process rather
> than go into enterprise manager and run data transformation.
> Is there any way to write a batch file or a set of command lines which
> will do this?
> Thanks.
> Monicasqlsql

Converting (too big)Raw into Hex

Hi there,

Here at my work(in Germany) i have a big problem:

Once a week there is a sqlscript, which should run and store data to a txt file.

There is a tablle in which imagedata is stored in RAW format(that one with small boxes, Qmarks and dots...).

Now i want to export it to the txtfile as HEX, so i can decode it by php further.

With the thumbnail, also stores there everything is fine, the SQL looks that way:

SELECt hex(thumbnail) FROM picTable where id_pic=54985

The Data is then displayed as HEX. But the standart picture is to big. When i use the statement:
SELECt hex(bigpic) FROM picTable where id_pic=54985

i got the error message:

An error occurred while running the query.

The data type, length, or value of argument 1 of HEX is invalid.

(SQL code = -171, SQL state = 42815)

After some research i found that the maximum lenght is 16 336 bytes for the HEX-operation. The picture is nearly 30 000 bytes... :shocked:
Have anyone an idea how to fix that?
I am not able here to accsess to the database direct...

I have been working for days on it.Uahh, wrong forum. Can anyone move this to SQL?|||the SQL forum is for standard SQL

i'm guessing you want this moved to the SQL Server forum

:)|||Still not solved...|||What is this "hex" function you are referring to? I could not find any reference to it in BOL (though it certainly would be a handy one to have!).

Regardless, assuming that there actually IS such an animal, can you consider breaking up the input data by sub-sections under your maximum size in the hex() function?

Such as using SUBSTRING ( expression , start , length )?

And then loop until the whole RAW data block is processed completely in bite-size chunks?

Tuesday, March 20, 2012

Convert/Cast from Varchar to decimal

guys, i've got a quick question on uploading a .txt or .csv file to a table
in sql server 2000.
i had been using a Bulk Insert to a dummy table where all columns are varcha
r.
then selecting that table and running it thru a for each loop in an asp.net
application and attempting the conversion there just using Cdbl(datarow.Item
(0))
or Cdec(datarow.Item(0)).
is there a better way to do this right on the database itself?
because it seems like somewhere an implicit rounding is occuring so i'll get
55.00 where 55.50 should be.
the problem i think is the inconsistant values, but, i thought i'd ask the r
eal experts.
as some of the values in the .csv (formerly .xls) file are 33.02, some are w
hole numbers 234 and even others are 55.5.
ive tried using Cast(Amount as Decimal(5,2)) in an insert statement and the
consistant error i get is "Arithmentic overflow converting numeric to data t
ype numeric"
if anyone has any suggestions, i'd really appreciate it.
thanks again
rik
****************************************
******************************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...Did you try altering that column in the dummy table to numeric(5, 2) instead
varchar?
AMB
"rik butcher" wrote:

> guys, i've got a quick question on uploading a .txt or .csv file to a tabl
e in sql server 2000.
> i had been using a Bulk Insert to a dummy table where all columns are varc
har.
> then selecting that table and running it thru a for each loop in an asp.ne
t
> application and attempting the conversion there just using Cdbl(datarow.It
em(0))
> or Cdec(datarow.Item(0)).
> is there a better way to do this right on the database itself?
> because it seems like somewhere an implicit rounding is occuring so i'll g
et 55.00 where 55.50 should be.
> the problem i think is the inconsistant values, but, i thought i'd ask the
real experts.
> as some of the values in the .csv (formerly .xls) file are 33.02, some ar
e whole numbers 234 and even others are 55.5.
> ive tried using Cast(Amount as Decimal(5,2)) in an insert statement and th
e consistant error i get is "Arithmentic overflow converting numeric to data
type numeric"
> if anyone has any suggestions, i'd really appreciate it.
> thanks again
> rik
> ****************************************
******************************
> Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
> Comprehensive, categorised, searchable collection of links to ASP & ASP.NE
T resources...
>|||Why are all the columns of your dummy table all varchar? Assuming that
the data is clean, you can create the target table with a column of the
desired decimal type and have nothing else to do about conversion.
As far as the error you're seeing with CAST, it indicates that there is
a value in the [Amount] column that represents a value too big for
decimal(5,2), in other words, greater than 999.99 or less than -999.99.
Again assuming that the data is clean, CAST should work if the target
type can hold the values. You'll get a different error if you have non-
numeric strings, like 'abc':
Server: Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.
I don't know the specifications of the Cdbl and Cdec functions, so I won't
comment on why some values seem to be changed more than rounding
should cause.
Steve Kass
Drew University
rbutch@.coair.com wrote:

>guys, i've got a quick question on uploading a .txt or .csv file to a table
in sql server 2000.
>i had been using a Bulk Insert to a dummy table where all columns are varch
ar.
>then selecting that table and running it thru a for each loop in an asp.net
>application and attempting the conversion there just using Cdbl(datarow.Ite
m(0))
>or Cdec(datarow.Item(0)).
>is there a better way to do this right on the database itself?
>because it seems like somewhere an implicit rounding is occuring so i'll ge
t 55.00 where 55.50 should be.
>the problem i think is the inconsistant values, but, i thought i'd ask the
real experts.
> as some of the values in the .csv (formerly .xls) file are 33.02, some are
whole numbers 234 and even others are 55.5.
>ive tried using Cast(Amount as Decimal(5,2)) in an insert statement and the
consistant error i get is "Arithmentic overflow converting numeric to data
type numeric"
>if anyone has any suggestions, i'd really appreciate it.
>thanks again
>rik
> ****************************************
******************************
>Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
>Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...
>|||thanks guys. you both were right. using numeric(5,2) worked but i still had
to widen that column again [that's what the overflow message was referring t
o] - so, i dont have to use a dummy table. and bcp bulk insert is working li
ke a charm.
i just had to look thru the actual values and there it was.
sometimes its the simplest things - and i appreciate you guys setting me str
aight on this.
thanks again
rik
****************************************
******************************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...

convert word doc to pdf

I have to convert word doc to pdf file use asp net.

I think maybe it possible make report in the report services, and then save them in pdf format.

but I dont know if I can make report from doc file.
and also if I can get the url of the file by query string.

Is it possible?

thanks!try again......|||

Do you have static Word documents that need 1-time conversion, or do you have Word documents that represent report styles or definitions that you want to export to PDF regularly with different data? In the first case, I'd say RS is not the right tool. In the second case, I think you'll get good results by designing the report definition from scratch using Report Designer, using the Word documents as prototypes.

Monday, March 19, 2012

Convert varchar to datetime

Hi,
I have what seems to be a simple issue, yet I can't get it to work:
I have a table that I have imported into SQL via a .txt file , one of the
fields holds a date (which was originally in the format of '122499'). I
added, based on certain criteria a '19' or '20' in front of the year to make
it '12241999' (still in a varchar type). But now when I try to insert it
into my final table which has a datatype as datetime, I'm having
difficulties, even if I try to convert or cast to datetime, I get the error
of:
Server: Msg 242, Level 16, State 3, Line 1
The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value.
I have read that if it is not in the default sql datetime format, this error
will appear, but I do seem to have it in the default order of mm/dd/yyyy.
Any suggestions?
Thank you in advance!Transpose the year to the beginning of the string. Instead of using CONVERT
just say:
RIGHT(col_name, 4) + LEFT(col_name, 4)
YYYYMMDD is the recommended format to guarantee. All these other format
(mmddyy, mmddyyyy, m/d/y, d/m/y, etc.) are completely and utterly for the
birds.
Please see http://www.karaszi.com/SQLServer/info_datetime.asp
"Patrice" <Patrice@.discussions.microsoft.com> wrote in message
news:BCAB2D7A-D6A9-4952-81C7-39114E913AE2@.microsoft.com...
> Hi,
> I have what seems to be a simple issue, yet I can't get it to work:
> I have a table that I have imported into SQL via a .txt file , one of the
> fields holds a date (which was originally in the format of '122499'). I
> added, based on certain criteria a '19' or '20' in front of the year to
> make
> it '12241999' (still in a varchar type). But now when I try to insert it
> into my final table which has a datatype as datetime, I'm having
> difficulties, even if I try to convert or cast to datetime, I get the
> error
> of:
> Server: Msg 242, Level 16, State 3, Line 1
> The conversion of a char data type to a datetime data type resulted in an
> out-of-range datetime value.
> I have read that if it is not in the default sql datetime format, this
> error
> will appear, but I do seem to have it in the default order of mm/dd/yyyy.
> Any suggestions?
> Thank you in advance!
>|||Hi Aaron,
I tried what you suggested and it does transpose the date in my table, of
course, but I still get the same error when trying to insert that field into
my fact table which has a datetime datatype - do I still need to convert or
cast that field into datetime datatype?
"Aaron Bertrand [SQL Server MVP]" wrote:

> Transpose the year to the beginning of the string. Instead of using CONVE
RT
> just say:
> RIGHT(col_name, 4) + LEFT(col_name, 4)
> YYYYMMDD is the recommended format to guarantee. All these other format
> (mmddyy, mmddyyyy, m/d/y, d/m/y, etc.) are completely and utterly for the
> birds.
> Please see http://www.karaszi.com/SQLServer/info_datetime.asp
>
>
> "Patrice" <Patrice@.discussions.microsoft.com> wrote in message
> news:BCAB2D7A-D6A9-4952-81C7-39114E913AE2@.microsoft.com...
>
>|||> I tried what you suggested and it does transpose the date in my table, of
> course, but I still get the same error when trying to insert that field
> into
> my fact table which has a datetime datatype - do I still need to convert
> or
> cast that field into datetime datatype?
No, but you should check if any of the data was bogus (my guess is there is
at least one) by SELECT COUNT(*) FROM OriginalTable WHERE ISDATE(Column) = 0
Just because you transpose 13131999 to 19991313 does not make it a valid
date. :-)
And thus, you see why date/time should always be stored as such, and never
as char.
A|||You are so very right. Problem solved - thank you kindly!
"Aaron Bertrand [SQL Server MVP]" wrote:

> No, but you should check if any of the data was bogus (my guess is there i
s
> at least one) by SELECT COUNT(*) FROM OriginalTable WHERE ISDATE(Column) =
0
> Just because you transpose 13131999 to 19991313 does not make it a valid
> date. :-)
> And thus, you see why date/time should always be stored as such, and never
> as char.
> A
>
>

Sunday, March 11, 2012

Convert text file format

Hi,

How can I convert a text file (.txt) into SQL in ASP.net 2.0 ? The sample of the file format is like that ...

09/03/2007 08:41 "Fung, Kitty" Granted Access D1 Main 2354 111

09/03/2007 08:42 "Ng, Jaclyn" Granted Access D1 Main 21906 18

09/03/2007 08:42 "Leung, Agnes" Granted Access D1 Main 21920 18

Cheers

Hi Stephen Ho,

How do you want to convert this text file into SQL?

|||

This is not standard text file (comma delimited or fixed fields) so you have to create your own parser so write application which will :

1 read line of text

2 parse line to fields (if you need data in fields)

3 insert fields into table row (or whole line as single field content)

4 check if next line exists and if yes go to step 1

but maybe you can change the format how your events are logged to file for example to comma delimited format and it will be easier to import it to SQL using SSIS package.

Thursday, March 8, 2012

Convert string to DateTime

Hi.
I get dates from a text file on this format: 200604281050. What would be the
easiest way to convert it to DateTime format, from char(12)? The example
should be as in: 04.28.2006 10:50 AM (or 28.04.2006. 10:50).
Do I have to build the DateTime field manually through PL/SQL ?
Any hints appreciated
Kind regards
Mr. SmithCAST(LEFT(YourCol,8) + ' ' + RIGHT(YourCol,4) AS DATETIME)
Andrew J. Kelly SQL MVP
"Mr. Smith" <nospam@.blindfolded.gone> wrote in message
news:%23a%23OiT5kGHA.1640@.TK2MSFTNGP02.phx.gbl...
> Hi.
> I get dates from a text file on this format: 200604281050. What would be
> the easiest way to convert it to DateTime format, from char(12)? The
> example should be as in: 04.28.2006 10:50 AM (or 28.04.2006. 10:50).
> Do I have to build the DateTime field manually through PL/SQL ?
> Any hints appreciated
> Kind regards
> Mr. Smith
>|||Andrew, it failed
DECLARE @.st VARCHAR (20)
SET @.st='200604281050'
--select CAST(LEFT(@.st,8) + ' ' + RIGHT(@.st,4) AS DATETIME)
--Server: Msg 242, Level 16, State 3, Line 4
--The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value.
SELECT CAST(LEFT(@.st,8)+' ' +SUBSTRING(@.st,9,2)+':'+RIGHT(@.st,2) AS
DATETIME)
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:ecRpjY5kGHA.1264@.TK2MSFTNGP05.phx.gbl...
> CAST(LEFT(YourCol,8) + ' ' + RIGHT(YourCol,4) AS DATETIME)
> --
> Andrew J. Kelly SQL MVP
> "Mr. Smith" <nospam@.blindfolded.gone> wrote in message
> news:%23a%23OiT5kGHA.1640@.TK2MSFTNGP02.phx.gbl...
>|||Try this:
DECLARE @.st VARCHAR (20)
SET @.st='200604281050'
SELECT CONVERT(DATETIME, LEFT(@.st, 8), 112)+CONVERT(DATETIME, SUBSTRING(@.st,
9, 2) + ':' + SUBSTRING(@.st, 11, 2), 114)|||Sorry you need to add the :
Andrew J. Kelly SQL MVP
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eaEycg5kGHA.3512@.TK2MSFTNGP03.phx.gbl...
> Andrew, it failed
> DECLARE @.st VARCHAR (20)
> SET @.st='200604281050'
> --select CAST(LEFT(@.st,8) + ' ' + RIGHT(@.st,4) AS DATETIME)
> --Server: Msg 242, Level 16, State 3, Line 4
> --The conversion of a char data type to a datetime data type resulted in
> an out-of-range datetime value.
> SELECT CAST(LEFT(@.st,8)+' ' +SUBSTRING(@.st,9,2)+':'+RIGHT(@.st,2) AS
> DATETIME)
>
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:ecRpjY5kGHA.1264@.TK2MSFTNGP05.phx.gbl...
>|||Mr Smith
Why are you using PL/SQL? Isn't that Oracle's SQL dialect?
HTH
Kalen Delaney, SQL Server MVP
"Mr. Smith" <nospam@.blindfolded.gone> wrote in message
news:%23a%23OiT5kGHA.1640@.TK2MSFTNGP02.phx.gbl...
> Hi.
> I get dates from a text file on this format: 200604281050. What would be
> the easiest way to convert it to DateTime format, from char(12)? The
> example should be as in: 04.28.2006 10:50 AM (or 28.04.2006. 10:50).
> Do I have to build the DateTime field manually through PL/SQL ?
> Any hints appreciated
> Kind regards
> Mr. Smith
>|||hehe - I was waiting for someone to ask that question. ;)
*mike hodgson*
http://sqlnerd.blogspot.com
Kalen Delaney wrote:

>Mr Smith
>Why are you using PL/SQL? Isn't that Oracle's SQL dialect?
>
>|||So why didn't you?
--
HTH
Kalen Delaney, SQL Server MVP
"Mike Hodgson" <e1minst3r@.gmail.com> wrote in message news:%23C92PRClGHA.145
6@.TK2MSFTNGP04.phx.gbl...
hehe - I was waiting for someone to ask that question. ;)
mike hodgson
http://sqlnerd.blogspot.com
Kalen Delaney wrote:
Mr Smith
Why are you using PL/SQL? Isn't that Oracle's SQL dialect?|||What I meant was when I was reading through the thread I was thinking
"did anyone notice that the original poster mentioned PL/SQL" and then I
got to your post (Mozilla Thunderbird displays yours last in the thread
when the thread is collapsed). As such I didn't need to ask because you
already had.
*mike hodgson*
http://sqlnerd.blogspot.com
Kalen Delaney wrote:
> So why didn't you?
> --
> HTH
> Kalen Delaney, SQL Server MVP
>
> "Mike Hodgson" <e1minst3r@.gmail.com <mailto:e1minst3r@.gmail.com>>
> wrote in message news:%23C92PRClGHA.1456@.TK2MSFTNGP04.phx.gbl...
> hehe - I was waiting for someone to ask that question. ;)
> --
> *mike hodgson*
> http://sqlnerd.blogspot.com
>
> Kalen Delaney wrote:
>|||:-)
HTH
Kalen Delaney, SQL Server MVP
"Mike Hodgson" <e1minst3r@.gmail.com> wrote in message
news:uUF31dClGHA.4776@.TK2MSFTNGP05.phx.gbl...
What I meant was when I was reading through the thread I was thinking "did
anyone notice that the original poster mentioned PL/SQL" and then I got to
your post (Mozilla Thunderbird displays yours last in the thread when the
thread is collapsed). As such I didn't need to ask because you already had.
mike hodgson
http://sqlnerd.blogspot.com
Kalen Delaney wrote:
So why didn't you?
HTH
Kalen Delaney, SQL Server MVP
"Mike Hodgson" <e1minst3r@.gmail.com> wrote in message
news:%23C92PRClGHA.1456@.TK2MSFTNGP04.phx.gbl...
hehe - I was waiting for someone to ask that question. ;)
mike hodgson
http://sqlnerd.blogspot.com
Kalen Delaney wrote:
Mr Smith
Why are you using PL/SQL? Isn't that Oracle's SQL dialect?

convert stored procedures returned output to varchar from int?

I have 1 files, one is .sql and another is stored procedure. SQL file will call the stored procedure by passing the variables setup in the SQL file. However, everything ran well except at the end, I try to get the return value from SP to my SQL file ... which will send notification email. But, I get the following msg ... I am not sure how to fix this ... help!!! :(

Syntax error converting the varchar value 'ABC' to a column of data type int.

SQL file

======================

DECLARE @.S AS VARCHAR(1000)

EXEC @.S = PDT.DBO.SP_RPT
'ABC'

SELECT CONTENT = @.S -- this is the value I am trying to pass as content of the email

EXEC PRODUCTION.DBO.SENDEMAIL'xxx@.hotmail.com', 'Notification', @.S

======================

Stored Procedure

======================

CREATE procedure sp_RPT
( @.array varchar(1000) )
AS

DECLARE @.content AS VARCHAR(2000)

SET @.content = 'RPT: ' + @.array + ' loaded successfully '

SET @.array = 'ABC'
RETURN CONVERT(VARCHAR(1000),@.array)


GO

try

cast( @.array as varchar(1000))

Hope this help

|||Don't use RETURN values in that manner. Either use an output parameter, or a resultset. RETURN values should be used as a control channel, not as a data channel; RETURN's purpose is to terminate control of a stored procedure immediately and also to report on how control was terminated (0 = normal/good, anything else is abnormal/bad).

Wednesday, March 7, 2012

Convert sql 7 file to msde 2000

is there any way I can convert a sql7 file to msde 2000.
I don't have sql 7 running, I have msde 2000 running
A detached SQL7 mdf file can be attached to SQL 2000 with an automatic
conversion to the newer platform. The same is true with backups.
Jim
"Slim" <Slim@.slim> wrote in message
news:uyGH7VIJEHA.2884@.TK2MSFTNGP12.phx.gbl...
> is there any way I can convert a sql7 file to msde 2000.
> I don't have sql 7 running, I have msde 2000 running
>
|||is this true for MSDE 2000, not sql 2000
"Jim Young" <thorium48@.hotmail.com> wrote in message
news:ezRsqfIJEHA.3704@.TK2MSFTNGP11.phx.gbl...
> A detached SQL7 mdf file can be attached to SQL 2000 with an automatic
> conversion to the newer platform. The same is true with backups.
> Jim
> "Slim" <Slim@.slim> wrote in message
> news:uyGH7VIJEHA.2884@.TK2MSFTNGP12.phx.gbl...
>
|||Yes, its the same for MSDE 2000.
Jim
"Slim" <Slim@.slim> wrote in message
news:eTwYwyIJEHA.232@.TK2MSFTNGP12.phx.gbl...
> is this true for MSDE 2000, not sql 2000
>
> "Jim Young" <thorium48@.hotmail.com> wrote in message
> news:ezRsqfIJEHA.3704@.TK2MSFTNGP11.phx.gbl...
>
|||Hi,
I read this thread and just want to be sure, because I have a similar problem.
I have the SQL 7 Version already running on my system, because I installed it with an application I can't identify yet.
Now I need to install MSDE2000A, because another (new to install) application demands it.
Do I have to uninstall SQL 7 before or will the installation of MSDE2000A upgrade SQL 7. Or will there be both working?
Will the old application run with the new MSDE?
I'd be happy to learn about all this.