Showing posts with label text. Show all posts
Showing posts with label text. Show all posts

Tuesday, March 27, 2012

Foreach loop for DBASE IV problem

I've followed the steps on how to use the ForEach loop container using a Flat Text file and it's working fine. I tried reading the text file and put it in my SQL table. However, I have some DBF files as well and the ForEach loop does not work at all with my DBF files.

Here is my scenario:

A connection manager pointed to C:\DBF_FILES

On the Control Flow: a Foreach loop container with Foreach file enumerator. (checks for IFUL*.DBF files and retrieves the Fully qualified name.

Within the foreach loop container is my DataFlow (import)

Within the dataflow:

OLEDB datasource
data access mode: Table name or View Name variable
Variable nam: username::Filefound

Now from this point on, I'm already having problems, here is the error:

An OLEDB error has occured.
An OLEDB record is available. Source: "Microsoft OLE DB Provider for ODBC Drivers.
Data source name not found and no default driver specified.
Error at data flow task...

There is also some error that say i don't have a destination table specified. Plus the error is on the OLEDB datasource not having a destination table? I don't understand this part.

Please help!

From what I understand of your post in my thread, I think what you want to do is simple. On the Foreach loop set the Folder to C:\DBF_FILES, set Files to *.dbf and select the "Name only" radio box in teh Retrieve file name.

That should set your configured variable in the Variable mapping to the name of the dbf file for each iteration. In your DataFlow set the data access mode to "Table name of view name variable" and the variable to the one you used in the Foreach variable mapping.

|||

Oh you should note, that you can only open one type of DBF file with that OLE DB Source. Meaning, all the files will need to have the same schema. If you have files with different content your going to either have to select them and handle the differences before this part. I have a couple ideas but it really depends on what you situation is.

|||

I think I see your problem, I actually put something together really quick to test that idea. I'll have to think about it a bit more later.

|||

Thanks Dan,

Yup, i only have the same schema for all the DBF files that I'm trying to retrieve. If I test the data flow with an implicit database name, it works fine. It's when I put it to the Foreach loop that I'm having the problem.

When I test the foreach loop with flat file, it works fine, but when I use the OLEDB, that's when it fails, I think I am following everything that needs to be done, it's just that all the samples for foreach loop has flat files for data source, and I expect it to be the same to the other types of data source. Maybe there is a missing link when the data source is not a flat file...

|||

Opps, I didn't have my Connection manager pointing to the right directory. What I described does in fact work. I'll try and post up some screen captures of how I have the package setup and perhaps you can see what isn' t configured right on your end.

This is about what I can write-up at the momment.

http://www.infrandom.com/42/Blog/tabid/53/EntryID/2/Default.aspx

|||

I've been doing and followed the steps exactly as you have laid out. My problem is on the OLEDB source. When I fil up the: OLEDB Connection Manager, data source mode and the variable name, when I click OK, it gives me the error:

Error at Data Flow task [OLE DB Source(431)] A destination table name has not been provided.

I really really appreciate the screen caps that you have provided. It really helps a lot. However, it is on that OLEDB source that I can't click OK due to the error, although my screen looks exactly like yours already.

Is there perhaps something that's not installed on my machine?

Thanks a lot.

|||

Another thing that I'm playing around just to be able to fix this is giving my variable a valid initial value. I am sure that the DBF file exists in the list but the error that I get when I do that is:

Opening a rowset for 'TBLNAME' failed. Check that the object exist in the database.

I tried TBLNAME.DBF, I tried TBLNAME only, but it just can't find it.

I made DBASE IV a version V but it said couldn't find installable ISAM. So I put back the DBASE IV.

On OLEDB Source:

The thing is I made my table access mode as table or view, and I choose TBLNAME from the list, I am fine. The problem is when i make my table access mode as 'table name or view name variable' and on the variable, i select my variable with my initial value as TBLNAME, it just can't find it.

I'm already lost. I gotta get some fresh air.

|||

View the variables, if you scroll the pane out, you can set the initial value of the variable in the designer. Give it a valid file name for a file in the directory. (There has to be a file present in the directory design time at least).

|||

I got that error when my Foreach loop directory and my Connection Manager directory were not point to the same directory. Once I updated to connection manager to the same directory I was able to run the package. Again, once you set the detault value of the variable just name no extension I think you should have it.

|||

Whew!!!

sometimes, a fresh air is really what it takes to get the mind cleared out.

Yup, I give my variable a valid file name. The problem was that only the DBF files were in that directory, not the index files. So I copied the index files as well, and it's now doing it's thing.

I followed everything that you have laid out on your screen caps.

Added a valid value to the variable. Made sure that the name retrieval is set to 'NAME only'. I set it to 'fully qualified path' at first, which contributed to the error. And finally, make sure that both the DBF and CDX files are present.

THANKS A LOT!!!

Really appreciate it.

|||

Glad you got it working!

sql

Monday, March 26, 2012

Forcing page breaks

Hello,
Apologies if this is a silly question. I am using Reporting services with
ODBC to convert print image text files into pdb files. Each record/line of
the file has one character code then the data for the line of the report. I
used odbc to describe the file to have 2 columns. The columns are ID and
Data.
Now for the question: I need to force a page break whenever the contents of
the ID column are a '1'. THis sounds like it should be really easy, but I
cannot seem to figure out how to do this.
ThanksI have an example on www.msbicentral.com which allows you to do a page break
after X number of lines. The example (if I remember correctly) uses an
expression for the page break. You could simply change the expression.
Search for Page or Page Break in the Downloads->Reporting Services ->RDL
section
--
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
"Stan" <Stan@.discussions.microsoft.com> wrote in message
news:DB2E845D-875B-4770-8C3E-4D0E06ACCFBE@.microsoft.com...
> Hello,
> Apologies if this is a silly question. I am using Reporting services with
> ODBC to convert print image text files into pdb files. Each record/line
> of
> the file has one character code then the data for the line of the report.
> I
> used odbc to describe the file to have 2 columns. The columns are ID and
> Data.
> Now for the question: I need to force a page break whenever the contents
> of
> the ID column are a '1'. THis sounds like it should be really easy, but I
> cannot seem to figure out how to do this.
> Thanks|||Wayne,
Thanks for the tip. Unfortunately, I cannot seem to get it to work. My
data is tabular and not a matrix (tho I have tried both). When ever I add
any group the order of the data gets all fubar(ed) and I cannot seem to stop
it from doing this. The darn reports takes all the ID=1 rows(which is the
first line of each page) and puts them all at the top of the report.
Any more help you can off would be appreciated, but as always the search
continues.
Thanks
Stan
"Wayne Snyder" wrote:
> I have an example on www.msbicentral.com which allows you to do a page break
> after X number of lines. The example (if I remember correctly) uses an
> expression for the page break. You could simply change the expression.
> Search for Page or Page Break in the Downloads->Reporting Services ->RDL
> section
> --
> 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
> "Stan" <Stan@.discussions.microsoft.com> wrote in message
> news:DB2E845D-875B-4770-8C3E-4D0E06ACCFBE@.microsoft.com...
> > Hello,
> >
> > Apologies if this is a silly question. I am using Reporting services with
> > ODBC to convert print image text files into pdb files. Each record/line
> > of
> > the file has one character code then the data for the line of the report.
> > I
> > used odbc to describe the file to have 2 columns. The columns are ID and
> > Data.
> >
> > Now for the question: I need to force a page break whenever the contents
> > of
> > the ID column are a '1'. THis sounds like it should be really easy, but I
> > cannot seem to figure out how to do this.
> >
> > Thanks
>
>|||I would love to hear a better answer, but if there isn't any other way...
How about using a custom function that acts as a counter that incremented
every time there was a 1? So the data would look something like:
counter ID Data
0 | 0 | xyz
0 | 0 | xyz
0 | 0 | xyz
1 | 1 | xyz
1 | 0 | xyz
1 | 0 | xyz
2 | 1 | xyz
2 | 0 | xyz
2 | 0 | xyz
etc.
Then, you could group by that function and put page breaks after each group.
A simple function could look something like:
Private x As Integer
Public Function addone(ByVal num As Integer) As Integer
x = x + num
Return x
End Function
The function doesn't actually need to be on the report, just use it to
group. Insert a group and for the expression:
=code.addone(Fields!id.value)
Mike G.
"Stan" <Stan@.discussions.microsoft.com> wrote in message
news:191002EE-50DD-4FEA-80DC-70A5D3A95DB4@.microsoft.com...
> Wayne,
> Thanks for the tip. Unfortunately, I cannot seem to get it to work. My
> data is tabular and not a matrix (tho I have tried both). When ever I add
> any group the order of the data gets all fubar(ed) and I cannot seem to
> stop
> it from doing this. The darn reports takes all the ID=1 rows(which is the
> first line of each page) and puts them all at the top of the report.
> Any more help you can off would be appreciated, but as always the search
> continues.
> Thanks
> Stan
>
> "Wayne Snyder" wrote:
>> I have an example on www.msbicentral.com which allows you to do a page
>> break
>> after X number of lines. The example (if I remember correctly) uses an
>> expression for the page break. You could simply change the expression.
>> Search for Page or Page Break in the Downloads->Reporting Services ->RDL
>> section
>> --
>> 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
>> "Stan" <Stan@.discussions.microsoft.com> wrote in message
>> news:DB2E845D-875B-4770-8C3E-4D0E06ACCFBE@.microsoft.com...
>> > Hello,
>> >
>> > Apologies if this is a silly question. I am using Reporting services
>> > with
>> > ODBC to convert print image text files into pdb files. Each
>> > record/line
>> > of
>> > the file has one character code then the data for the line of the
>> > report.
>> > I
>> > used odbc to describe the file to have 2 columns. The columns are ID
>> > and
>> > Data.
>> >
>> > Now for the question: I need to force a page break whenever the
>> > contents
>> > of
>> > the ID column are a '1'. THis sounds like it should be really easy,
>> > but I
>> > cannot seem to figure out how to do this.
>> >
>> > Thanks
>>|||Mike,
I was on this track, but could not get it right. You hit the nail right on
the head.
Thanks!!!
Stan
"Mike G." wrote:
> I would love to hear a better answer, but if there isn't any other way...
> How about using a custom function that acts as a counter that incremented
> every time there was a 1? So the data would look something like:
> counter ID Data
> 0 | 0 | xyz
> 0 | 0 | xyz
> 0 | 0 | xyz
> 1 | 1 | xyz
> 1 | 0 | xyz
> 1 | 0 | xyz
> 2 | 1 | xyz
> 2 | 0 | xyz
> 2 | 0 | xyz
> etc.
> Then, you could group by that function and put page breaks after each group.
> A simple function could look something like:
> Private x As Integer
> Public Function addone(ByVal num As Integer) As Integer
> x = x + num
> Return x
> End Function
> The function doesn't actually need to be on the report, just use it to
> group. Insert a group and for the expression:
> =code.addone(Fields!id.value)
> Mike G.
> "Stan" <Stan@.discussions.microsoft.com> wrote in message
> news:191002EE-50DD-4FEA-80DC-70A5D3A95DB4@.microsoft.com...
> > Wayne,
> >
> > Thanks for the tip. Unfortunately, I cannot seem to get it to work. My
> > data is tabular and not a matrix (tho I have tried both). When ever I add
> > any group the order of the data gets all fubar(ed) and I cannot seem to
> > stop
> > it from doing this. The darn reports takes all the ID=1 rows(which is the
> > first line of each page) and puts them all at the top of the report.
> >
> > Any more help you can off would be appreciated, but as always the search
> > continues.
> >
> > Thanks
> >
> > Stan
> >
> >
> >
> > "Wayne Snyder" wrote:
> >
> >> I have an example on www.msbicentral.com which allows you to do a page
> >> break
> >> after X number of lines. The example (if I remember correctly) uses an
> >> expression for the page break. You could simply change the expression.
> >>
> >> Search for Page or Page Break in the Downloads->Reporting Services ->RDL
> >> section
> >>
> >> --
> >> 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
> >>
> >> "Stan" <Stan@.discussions.microsoft.com> wrote in message
> >> news:DB2E845D-875B-4770-8C3E-4D0E06ACCFBE@.microsoft.com...
> >> > Hello,
> >> >
> >> > Apologies if this is a silly question. I am using Reporting services
> >> > with
> >> > ODBC to convert print image text files into pdb files. Each
> >> > record/line
> >> > of
> >> > the file has one character code then the data for the line of the
> >> > report.
> >> > I
> >> > used odbc to describe the file to have 2 columns. The columns are ID
> >> > and
> >> > Data.
> >> >
> >> > Now for the question: I need to force a page break whenever the
> >> > contents
> >> > of
> >> > the ID column are a '1'. THis sounds like it should be really easy,
> >> > but I
> >> > cannot seem to figure out how to do this.
> >> >
> >> > Thanks
> >>
> >>
> >>
>
>

Wednesday, March 21, 2012

Force to Bottom of page

I have a text box as the last item on the report. It's just above the Page Footer. I want this textbox to always display at the bottom of the last page of the report. I can't seem to find a way to force this.

All help is appreciated.

Is there no way to do this? Is that why I've had no response?

|||

You could move the text box into the page footer and use a visibility expression:

=iif(Globals!PageNumber = Globals!TotalPages, false, true)

|||

Thanks for the response.

That is a good thought but the textbox contains a Paramater to the report which could be a multi line string. The textbox will grow with the string but the Footer doesn't seem to dynamically grow. And the size properties on the footer do not allow expressions.

Is there a way to force the footer to grow and shrink with the size of the objects in it?

Dave

force protocal encryption

This is a multi-part message in MIME format.
--=_NextPart_000_008F_01C503E2.52829930
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,
I could like to understand the SSL "force protocal encryption" on SQL = 2000, if I do this:
1: how much extra resource it will take to do encryption?
2: What certificate should we use, must we use certicate from public = certification authority?
3: how will the client side affected after I turn on force protocal = encryption? should it be transparent to them if we install public = certificate on the server?
4: Can client still connect to server using IP address, or must FQDN is = required?
Thanks
Frank
--=_NextPart_000_008F_01C503E2.52829930
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Hi,

I could like to understand the SSL = "force protocal encryption" on SQL 2000, if I do this:

1: how much extra resource it will take = to do encryption?
2: What certificate should we use, must = we use certicate from public certification authority?
3: how will the client side affected = after I turn on force protocal encryption? should it be transparent to them if we install public certificate on the server?
4: Can client still connect to server = using IP address, or must FQDN is required?

Thanks
Frank


--=_NextPart_000_008F_01C503E2.52829930--This is a multi-part message in MIME format.
--=_NextPart_000_009E_01C503EA.A15351F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I follow the MS link below and trying to Request New Certificate for SSL =using MMC, however, I cannot see "Request New Certificate" from the MMC =(under How to Configure the MMC Snap-in-->2-->b)
Is there other way to request a verisign certificate except from =certificate server?
Thanks
Frank
How to enable SSL encryption for SQL Server 2000 with Microsoft =Management Console
http://support.microsoft.com/kb/316898/EN-US/
"Frank" <signup0702@.sina.com> wrote in message =news:eEbJe85AFHA.1400@.TK2MSFTNGP11.phx.gbl...
Hi,
I could like to understand the SSL "force protocal encryption" on SQL =2000, if I do this:
1: how much extra resource it will take to do encryption?
2: What certificate should we use, must we use certicate from public =certification authority?
3: how will the client side affected after I turn on force protocal =encryption? should it be transparent to them if we install public =certificate on the server?
4: Can client still connect to server using IP address, or must FQDN =is required?
Thanks
Frank
--=_NextPart_000_009E_01C503EA.A15351F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

I follow the MS link below and trying to Request New Certificate =for SSL using MMC, however, I cannot see "Request New Certificate" from the MMC =(under How to Configure the MMC Snap-in-->2-->b)
Is there other way to request a =verisign certificate except from certificate server?
Thanks
Frank
How to enable SSL encryption for SQL Server 2000 =with Microsoft Management Console
http://support.microsoft.com/kb/316898/EN-US/">http://support.mic=rosoft.com/kb/316898/EN-US/
"Frank" wrote =in message news:eEbJe85AFHA.1400=@.TK2MSFTNGP11.phx.gbl...
Hi,

I could like to understand the SSL ="force protocal encryption" on SQL 2000, if I do this:

1: how much extra resource it will =take to do encryption?
2: What certificate should we use, =must we use certicate from public certification authority?
3: how will the client side affected =after I turn on force protocal encryption? should it be transparent to them if we install public certificate on the server?
4: Can client still connect to server =using IP address, or must FQDN is required?

Thanks
Frank



--=_NextPart_000_009E_01C503EA.A15351F0--

Monday, March 19, 2012

Force IS to use column headings

Hi,
I've got an IS package which reads a lot of records from a text file and loads that into the database. The text file has column such as Firstname, Lastname, phone number etc and same as the database table.

The problem:
IS works fine if I have the text file columns in the same order as the database columns but for example if have phone number in the place of firstname (in the text file) IS puts the phone numbers as firstname in the database and moves all the columns dow the order.

Is there anyway I could force IS to use the heading names in the text file and put it in the appropriate database columns?

Thanks guys...

The connection manager defines the ordering in the text file so if IS is putting your data into the wrong columns in the database it is because the connection manager is defined incorrectly. If your files vary their order of columns then you would need different connection managers (and therefore different sources) for each ordering.

Matt

|||Thanks for the reply but the problem I'm facing is the text file may not have some of the columns or the columns will be in different order etc. I don't know what the file contains at the time of loading.

Is it possible for me to get IS to load what ever columns are in the text file and just put null (in the database) for the once we are missing?

|||

If you really have no idea what is coming in until it's loaded, then my suggestion would be to load the text file, including the first row with the names, into a SQL table with columns called "col1", "col2", "col3" etc. up to the max you will have. That gets you over the problem of loading the table using a single data flow task.

Then the problem is one of how to split the data into the relevant columns in your "proper" destination table. ;-D

I'm still gettng my head round the new tools in SSIS, so personally I wouldn't know how to do it (maybe conditional split?). What I would do would be to write a T-SQL stored procedure to parse the first row and construct an SQL string to select the columns from the table.

The example below gives you the idea.

Hope this helps,

Rich

Code to follow --

CREATE TABLE [dbo].[tbl_RAW](

[col1] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col2] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col3] [varchar](50) COLLATE Latin1_General_CI_AS NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[tbl_People](

[Name] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[Phone] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[Sex] [varchar](50) COLLATE Latin1_General_CI_AS NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[tbl_ValueList](

[col1] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col2] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col3] [varchar](50) COLLATE Latin1_General_CI_AS NULL

) ON [PRIMARY]

GO

SET ANSI_PADDING OFF

TRUNCATE TABLE tbl_RAW;

TRUNCATE TABLE tbl_People;

TRUNCATE TABLE tbl_ValueList;

-- Populate RAW

INSERT INTO dbo.tbl_RAW

Values ('sex','Name','Phone');

INSERT INTO dbo.tbl_RAW

Values ('Male','Eric','1234');

INSERT INTO dbo.tbl_RAW

Values ('Male','Tim','00000');

INSERT INTO dbo.tbl_RAW

Values ('Female','Simone','9876');

INSERT INTO tbl_ValueList

SELECT top 1 *

FROM dbo.tbl_RAW

DECLARE @.ValueList varchar(50)

DECLARE @.strSQL varchar(100)

DECLARE @.col1value varchar(50)

SELECT @.ValueList = '(' + col1 +','+ col2 +','+ col3 +')' FROM tbl_ValueList

SELECT @.Col1Value = col1 FROM tbl_ValueList

SET @.strSQL = 'INSERT INTO dbo.tbl_People ' + @.ValueList + 'SELECT * FROM dbo.tbl_RAW WHERE col1 <> '''+ @.col1Value +''''

print @.strSQL

EXECUTE (@.strSQL)

SELECT * FROM dbo.tbl_People

-- End of Code--

|||

I'm having a similar problem.

I'm using CSVDE.exe to do a bulk export of Active Directory users. The problem is that the column order that CSVDE outputs seems to be non-deterministic.

If I dump the file, go into the connection and do a "Reset Columns", everything works fine. However, I would like to do the dump as part of my Control Flow, and I can't find a way to force a "Reset Columns" before the processing begins.

I know what columns I'm getting, just not the order they'll come in. I also know that the first row will have the column names in it.

Force IS to use column headings

Hi,
I've got an IS package which reads a lot of records from a text file and loads that into the database. The text file has column such as Firstname, Lastname, phone number etc and same as the database table.

The problem:
IS works fine if I have the text file columns in the same order as the database columns but for example if have phone number in the place of firstname (in the text file) IS puts the phone numbers as firstname in the database and moves all the columns dow the order.

Is there anyway I could force IS to use the heading names in the text file and put it in the appropriate database columns?

Thanks guys...

The connection manager defines the ordering in the text file so if IS is putting your data into the wrong columns in the database it is because the connection manager is defined incorrectly. If your files vary their order of columns then you would need different connection managers (and therefore different sources) for each ordering.

Matt

|||Thanks for the reply but the problem I'm facing is the text file may not have some of the columns or the columns will be in different order etc. I don't know what the file contains at the time of loading.

Is it possible for me to get IS to load what ever columns are in the text file and just put null (in the database) for the once we are missing?

|||

If you really have no idea what is coming in until it's loaded, then my suggestion would be to load the text file, including the first row with the names, into a SQL table with columns called "col1", "col2", "col3" etc. up to the max you will have. That gets you over the problem of loading the table using a single data flow task.

Then the problem is one of how to split the data into the relevant columns in your "proper" destination table. ;-D

I'm still gettng my head round the new tools in SSIS, so personally I wouldn't know how to do it (maybe conditional split?). What I would do would be to write a T-SQL stored procedure to parse the first row and construct an SQL string to select the columns from the table.

The example below gives you the idea.

Hope this helps,

Rich

Code to follow --

CREATE TABLE [dbo].[tbl_RAW](

[col1] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col2] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col3] [varchar](50) COLLATE Latin1_General_CI_AS NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[tbl_People](

[Name] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[Phone] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[Sex] [varchar](50) COLLATE Latin1_General_CI_AS NULL

) ON [PRIMARY]

GO

CREATE TABLE [dbo].[tbl_ValueList](

[col1] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col2] [varchar](50) COLLATE Latin1_General_CI_AS NULL,

[col3] [varchar](50) COLLATE Latin1_General_CI_AS NULL

) ON [PRIMARY]

GO

SET ANSI_PADDING OFF

TRUNCATE TABLE tbl_RAW;

TRUNCATE TABLE tbl_People;

TRUNCATE TABLE tbl_ValueList;

-- Populate RAW

INSERT INTO dbo.tbl_RAW

Values ('sex','Name','Phone');

INSERT INTO dbo.tbl_RAW

Values ('Male','Eric','1234');

INSERT INTO dbo.tbl_RAW

Values ('Male','Tim','00000');

INSERT INTO dbo.tbl_RAW

Values ('Female','Simone','9876');

INSERT INTO tbl_ValueList

SELECT top 1 *

FROM dbo.tbl_RAW

DECLARE @.ValueList varchar(50)

DECLARE @.strSQL varchar(100)

DECLARE @.col1value varchar(50)

SELECT @.ValueList = '(' + col1 +','+ col2 +','+ col3 +')' FROM tbl_ValueList

SELECT @.Col1Value = col1 FROM tbl_ValueList

SET @.strSQL = 'INSERT INTO dbo.tbl_People ' + @.ValueList + 'SELECT * FROM dbo.tbl_RAW WHERE col1 <> '''+ @.col1Value +''''

print @.strSQL

EXECUTE (@.strSQL)

SELECT * FROM dbo.tbl_People

-- End of Code--

|||

I'm having a similar problem.

I'm using CSVDE.exe to do a bulk export of Active Directory users. The problem is that the column order that CSVDE outputs seems to be non-deterministic.

If I dump the file, go into the connection and do a "Reset Columns", everything works fine. However, I would like to do the dump as part of my Control Flow, and I can't find a way to force a "Reset Columns" before the processing begins.

I know what columns I'm getting, just not the order they'll come in. I also know that the first row will have the column names in it.

Monday, March 12, 2012

for xml raw problem

Hi
I'm running a simple query with for xml raw on a table
one of columns in select clause here is of type text and stores xml
file itself.
The problem i'm facing is when I get this text back from this column I
get back unformatted xml
e.g
instead of getting <GPF> I get <GPF> etc
How do I get this column as formatted xml text ?
Thanks for help
Vishy>
> I'm running a simple query with for xml raw on a table
> one of columns in select clause here is of type text and stores xml
> file itself.
> The problem i'm facing is when I get this text back from this column I
> get back unformatted xml
> e.g
> instead of getting <GPF> I get <GPF> etc
> How do I get this column as formatted xml text ?
>
Hello
signs '<' and '>' are very important in XML because they show begin and end
of xml element, so when an element or attribute value has such signs it must
be changed into < and >. But when you open XML which contains such
substitution - using DOM or OPENXML in SQL you will get values with signs
'<', '>'. So I think that it sould not be a problem - siply try to process
XML which was generated and you will see that it has valid values of
elements/attributes.
I hope it helps,
Alwik|||Thanks Alwik for reply
I tried to create object on XmlDocument using LoadXml() method
it loads up the xml successfully but if I want to run any Xpath; it
fails
as <GPF> is not treated as <GPF> so I can't find GPF element
is there any work around?
Vishy|||Are you using SQL Server 2000 or 2005?
In the case of SQL Server 2000, you will have to use the explicit mode and
its !xml directive, if you want to have string data be inlined into the XML
structure.
In the case of SQL Server 2005, you can stick with the FOR XML RAW query,
but you need to cast the string data to XML in the select clause.
Best regards
Michael
"Vishy" <vishal.halbe@.gmail.com> wrote in message
news:1128445808.595093.141180@.g49g2000cwa.googlegroups.com...
> Thanks Alwik for reply
> I tried to create object on XmlDocument using LoadXml() method
> it loads up the xml successfully but if I want to run any Xpath; it
> fails
> as <GPF> is not treated as <GPF> so I can't find GPF element
> is there any work around?
> Vishy
>|||Thanks Michael for reply
I'm using SQL 2000
Vishy

for xml raw problem

Hi
I'm running a simple query with for xml raw on a table
one of columns in select clause here is of type text and stores xml
file itself.
The problem i'm facing is when I get this text back from this column I
get back unformatted xml
e.g
instead of getting <GPF> I get <GPF> etc
How do I get this column as formatted xml text ?
Thanks for help
Vishy
>
> I'm running a simple query with for xml raw on a table
> one of columns in select clause here is of type text and stores xml
> file itself.
> The problem i'm facing is when I get this text back from this column I
> get back unformatted xml
> e.g
> instead of getting <GPF> I get <GPF> etc
> How do I get this column as formatted xml text ?
>
Hello
signs '<' and '>' are very important in XML because they show begin and end
of xml element, so when an element or attribute value has such signs it must
be changed into < and >. But when you open XML which contains such
substitution - using DOM or OPENXML in SQL you will get values with signs
'<', '>'. So I think that it sould not be a problem - siply try to process
XML which was generated and you will see that it has valid values of
elements/attributes.
I hope it helps,
Alwik
|||Thanks Alwik for reply
I tried to create object on XmlDocument using LoadXml() method
it loads up the xml successfully but if I want to run any Xpath; it
fails
as <GPF> is not treated as <GPF> so I can't find GPF element
is there any work around?
Vishy
|||Are you using SQL Server 2000 or 2005?
In the case of SQL Server 2000, you will have to use the explicit mode and
its !xml directive, if you want to have string data be inlined into the XML
structure.
In the case of SQL Server 2005, you can stick with the FOR XML RAW query,
but you need to cast the string data to XML in the select clause.
Best regards
Michael
"Vishy" <vishal.halbe@.gmail.com> wrote in message
news:1128445808.595093.141180@.g49g2000cwa.googlegr oups.com...
> Thanks Alwik for reply
> I tried to create object on XmlDocument using LoadXml() method
> it loads up the xml successfully but if I want to run any Xpath; it
> fails
> as <GPF> is not treated as <GPF> so I can't find GPF element
> is there any work around?
> Vishy
>
|||Thanks Michael for reply
I'm using SQL 2000
Vishy

Wednesday, March 7, 2012

FOR XML AUTO, ELEMENTS Problem

I have a column ('ProblemResolution') in a table ('Incident') that holds plain text. I am doing a query against that column and converting the results to XML as follows:

Select ProblemResolution From Incident Where RowID = 2 FOR XML AUTO, ELEMENTS

The problem is the XML that is being generated. It appears the XML that is generated is illegal (in some cases) because if I save the resulting XML in a text file and load into Internet Explorer, IE generates errors.

Here is the plain text (actually part of it - enough to demo the problem) as stored in the column. The quotes are not stored.

"8/11/2006 dabonder -
Carol –

Thanks for the detail. I looked at the 6060 transaction and it was as you thought – these accounts are not set up in the .|
If the corresponding project account to 6060 would never be used in a time sheet or expense report then you would not need to have a.
I haven't had time to clarify this. If you want to discuss when you get time I would be happy to.

-D Abonder

D Abonder
Director of Consulting
Some Company
www.SomeCompany.com

Email: dgonder@.somecompany.com
Phone: 123-555-3450"

Here is the generated (illegal) XML:

<Incident><ProblemResolution>8/11/2006 dabonder -&#x0D;
&#x0D;
Carol –&#x0D;
&#x0D;
Thanks for the detail. I looked at the 6060 transaction and it was as you thought – these accounts are not set up in the .&#x0D;
&#x0D;
If the corresponding project account to 6060 would never be used in a time sheet or expense report then you would not need to have a.&#x0D;
&#x0D;
I haven&apos;t had time to clarify this. If you want to discuss when you get time I would be happy to.&#x0D;
&#x0D;
-D Abonder&#x0D;
&#x0D;
D Abonder&#x0D;
Director of Consulting&#x0D;
Some Company&#x0D;
www.SomeCompany.com&#x0D;
&#x0D;
Email: dgonder@.somecompany.com&#x0D;
Phone: 123-555-3450</ProblemResolution></Incident>

The problem is that the document contains invalid U+0000 characters that are not allowed in XML. FOR XML does not mark them as errors but outputs them anyway. You should clean your data in the table or when running your FOR XML expression or before passing the XML to the parser and remove the U+0000 code point or replace the &#x0D; with the zero-length string.

Best regards

Michael

Sunday, February 26, 2012

for passing text type argument to procedure

For parsing data > 8000 char I have defined a procedure that looks something like
create proc myproc @.doc text
as
blah blah blah
go

but now i need to pass text argument to it.
For that I need ::: declare @.newdoc text
and then call ::: exec myproc @.newdoc
but I cannot declare text type variable in the transact sql queries.

Is there a way out
thanksyou normally don't work directly with text, ntext and image data. When working with these types of data you normally pass pointers to the data and use functions/stored procedures to manipulate the data, TEXTPTR, WRITETEXT and UPDATETEXT. Check out "text and image data types" in Books On Line.