Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Wednesday, March 28, 2012

Problem with blob field in SQL Server

In SQLServer database i have stored a blob using updateblob function,
type of the table column is image.
When i use Selectblob statement to get the blob into a blob variable, i am getting only 32 KB of data. But with ASA i am getting the complete data..
How to get Complete data in SQL Server?

regds.,
rangaWhich data provider are you using?

Terrisql

Monday, March 26, 2012

Problem with an update

Hi, I've a table "Table1" with:
ID - Cod - Type - Value - Period
1-COD1-AAA-0-Jan
2-COD2-BBB-0-Feb
3-COD3-AAA-0-Feb
4-COD4-CCC-0-Feb
Now I want to UPDATE this records using a Second Table "Table2"
Type-Qt-Value-Period
AAA-10-10-Jan
AAA-3-2-Feb
BBB-3-2-Feb
CCC-4-6-Feb
...
If, in table1, I've AAA I want to search in table2 the value of type AAA in
the table1.period
If, in table1, I've BBB I want to search in table2 the value of type BBB in
the table1.period
How Can I create this update'
After the UPDATE, I would like to obtain:
ID - Cod - Type - Value - Period
1-COD1-AAA-100-Jan (value = 10*10)
2-COD2-BBB-6-Feb (value = 3*2)
3-COD3-AAA-6-Feb (value = 3*2)
4-COD4-CCC-24-Feb (value = 6*4)
ThanksIdentity wrote:
> Hi, I've a table "Table1" with:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-0-Jan
> 2-COD2-BBB-0-Feb
> 3-COD3-AAA-0-Feb
> 4-COD4-CCC-0-Feb
> Now I want to UPDATE this records using a Second Table "Table2"
> Type-Qt-Value-Period
> AAA-10-10-Jan
> AAA-3-2-Feb
> BBB-3-2-Feb
> CCC-4-6-Feb
> ...
> If, in table1, I've AAA I want to search in table2 the value of type AAA i
n
> the table1.period
> If, in table1, I've BBB I want to search in table2 the value of type BBB i
n
> the table1.period
>
> How Can I create this update'
> After the UPDATE, I would like to obtain:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-100-Jan (value = 10*10)
> 2-COD2-BBB-6-Feb (value = 3*2)
> 3-COD3-AAA-6-Feb (value = 3*2)
> 4-COD4-CCC-24-Feb (value = 6*4)
> Thanks
It really helps if you post DDL and INSERT statements instead of
sketches of tables - it could even save you some typing. Looking at the
information given it appears that the UPDATE is to be based on joining
the tables on type and period, but you've left us to guess whether
those two columns are unique in either table. If the combination of
those two columns isn't unique in Table2 then do you want to SUM the
multiple rows? If they aren't unique in Table1 then do you want the
same value figure to appear on multiple rows? If they are unique in
BOTH tables then is there a particular reason for having two tables
instead of one?
Notwithstanding the above uncertainties, here's my untested guess at
what you want:
UPDATE Table1
SET value =
(SELECT SUM(qt*value)
FROM Table2
WHERE type = Table1.type
AND period = Table1.period);
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Here's one method:
CREATE TABLE dbo.FirstTable
(
ID int NOT NULL
CONSTRAINT PK_FirstTable PRIMARY KEY,
Cod char(4) NOT NULL,
[Type] char(3) NOT NULL,
[Value] int NOT NULL,
Period char(3) NOT NULL
)
INSERT INTO dbo.FirstTable
SELECT 1,'COD1','AAA',0,'Jan'
UNION ALL SELECT 2,'COD2','BBB',0,'Feb'
UNION ALL SELECT 3,'COD3','AAA',0,'Feb'
UNION ALL SELECT 4,'COD4','CCC',0,'Feb'
CREATE TABLE dbo.SecondTable
(
[Type] char(3) NOT NULL,
[Value] int NOT NULL,
Qt int NOT NULL,
Period char(3) NOT NULL,
CONSTRAINT PK_SecondTable
PRIMARY KEY ([Type], Period)
)
INSERT INTO dbo.SecondTable
SELECT 'AAA',10,10,'Jan'
UNION ALL SELECT 'AAA',3,2,'Feb'
UNION ALL SELECT 'BBB',3,2,'Feb'
UNION ALL SELECT 'CCC',4,6,'Feb'
UPDATE dbo.FirstTable
SET
Value =
(SELECT [Value]*Qt
FROM dbo.SecondTable
WHERE
SecondTable.[Type] = FirstTable.[Type] AND
SecondTable.[Period] = FirstTable.[Period]
)
SELECT
ID,
Cod,
[Type],
[Value],
Period
FROM dbo.FirstTable
Hope this helps.
Dan Guzman
SQL Server MVP
"Identity" <id@.id.it> wrote in message
news:uQxOzbpoGHA.2256@.TK2MSFTNGP03.phx.gbl...
> Hi, I've a table "Table1" with:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-0-Jan
> 2-COD2-BBB-0-Feb
> 3-COD3-AAA-0-Feb
> 4-COD4-CCC-0-Feb
> Now I want to UPDATE this records using a Second Table "Table2"
> Type-Qt-Value-Period
> AAA-10-10-Jan
> AAA-3-2-Feb
> BBB-3-2-Feb
> CCC-4-6-Feb
> ...
> If, in table1, I've AAA I want to search in table2 the value of type AAA
> in
> the table1.period
> If, in table1, I've BBB I want to search in table2 the value of type BBB
> in
> the table1.period
>
> How Can I create this update'
> After the UPDATE, I would like to obtain:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-100-Jan (value = 10*10)
> 2-COD2-BBB-6-Feb (value = 3*2)
> 3-COD3-AAA-6-Feb (value = 3*2)
> 4-COD4-CCC-24-Feb (value = 6*4)
> Thanks|||Thanks for help!
But If I've many fields I must to use

> value =
> (SELECT SUM(qt*value)
> FROM Table2
> WHERE type = Table1.type
> AND period = Table1.period);
for all fields
Thankssql

Problem with an update

Hi, I've a table "Table1" with:
ID - Cod - Type - Value - Period
1-COD1-AAA-0-Jan
2-COD2-BBB-0-Feb
3-COD3-AAA-0-Feb
4-COD4-CCC-0-Feb
Now I want to UPDATE this records using a Second Table "Table2"
Type-Qt-Value-Period
AAA-10-10-Jan
AAA-3-2-Feb
BBB-3-2-Feb
CCC-4-6-Feb
...
If, in table1, I've AAA I want to search in table2 the value of type AAA in
the table1.period
If, in table1, I've BBB I want to search in table2 the value of type BBB in
the table1.period
How Can I create this update'
After the UPDATE, I would like to obtain:
ID - Cod - Type - Value - Period
1-COD1-AAA-100-Jan (value = 10*10)
2-COD2-BBB-6-Feb (value = 3*2)
3-COD3-AAA-6-Feb (value = 3*2)
4-COD4-CCC-24-Feb (value = 6*4)
ThanksIdentity wrote:
> Hi, I've a table "Table1" with:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-0-Jan
> 2-COD2-BBB-0-Feb
> 3-COD3-AAA-0-Feb
> 4-COD4-CCC-0-Feb
> Now I want to UPDATE this records using a Second Table "Table2"
> Type-Qt-Value-Period
> AAA-10-10-Jan
> AAA-3-2-Feb
> BBB-3-2-Feb
> CCC-4-6-Feb
> ...
> If, in table1, I've AAA I want to search in table2 the value of type AAA in
> the table1.period
> If, in table1, I've BBB I want to search in table2 the value of type BBB in
> the table1.period
>
> How Can I create this update'
> After the UPDATE, I would like to obtain:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-100-Jan (value = 10*10)
> 2-COD2-BBB-6-Feb (value = 3*2)
> 3-COD3-AAA-6-Feb (value = 3*2)
> 4-COD4-CCC-24-Feb (value = 6*4)
> Thanks
It really helps if you post DDL and INSERT statements instead of
sketches of tables - it could even save you some typing. Looking at the
information given it appears that the UPDATE is to be based on joining
the tables on type and period, but you've left us to guess whether
those two columns are unique in either table. If the combination of
those two columns isn't unique in Table2 then do you want to SUM the
multiple rows? If they aren't unique in Table1 then do you want the
same value figure to appear on multiple rows? If they are unique in
BOTH tables then is there a particular reason for having two tables
instead of one?
Notwithstanding the above uncertainties, here's my untested guess at
what you want:
UPDATE Table1
SET value = (SELECT SUM(qt*value)
FROM Table2
WHERE type = Table1.type
AND period = Table1.period);
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Here's one method:
CREATE TABLE dbo.FirstTable
(
ID int NOT NULL
CONSTRAINT PK_FirstTable PRIMARY KEY,
Cod char(4) NOT NULL,
[Type] char(3) NOT NULL,
[Value] int NOT NULL,
Period char(3) NOT NULL
)
INSERT INTO dbo.FirstTable
SELECT 1,'COD1','AAA',0,'Jan'
UNION ALL SELECT 2,'COD2','BBB',0,'Feb'
UNION ALL SELECT 3,'COD3','AAA',0,'Feb'
UNION ALL SELECT 4,'COD4','CCC',0,'Feb'
CREATE TABLE dbo.SecondTable
(
[Type] char(3) NOT NULL,
[Value] int NOT NULL,
Qt int NOT NULL,
Period char(3) NOT NULL,
CONSTRAINT PK_SecondTable
PRIMARY KEY ([Type], Period)
)
INSERT INTO dbo.SecondTable
SELECT 'AAA',10,10,'Jan'
UNION ALL SELECT 'AAA',3,2,'Feb'
UNION ALL SELECT 'BBB',3,2,'Feb'
UNION ALL SELECT 'CCC',4,6,'Feb'
UPDATE dbo.FirstTable
SET
Value = (SELECT [Value]*Qt
FROM dbo.SecondTable
WHERE
SecondTable.[Type] = FirstTable.[Type] AND
SecondTable.[Period] = FirstTable.[Period]
)
SELECT
ID,
Cod,
[Type],
[Value],
Period
FROM dbo.FirstTable
Hope this helps.
Dan Guzman
SQL Server MVP
"Identity" <id@.id.it> wrote in message
news:uQxOzbpoGHA.2256@.TK2MSFTNGP03.phx.gbl...
> Hi, I've a table "Table1" with:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-0-Jan
> 2-COD2-BBB-0-Feb
> 3-COD3-AAA-0-Feb
> 4-COD4-CCC-0-Feb
> Now I want to UPDATE this records using a Second Table "Table2"
> Type-Qt-Value-Period
> AAA-10-10-Jan
> AAA-3-2-Feb
> BBB-3-2-Feb
> CCC-4-6-Feb
> ...
> If, in table1, I've AAA I want to search in table2 the value of type AAA
> in
> the table1.period
> If, in table1, I've BBB I want to search in table2 the value of type BBB
> in
> the table1.period
>
> How Can I create this update'
> After the UPDATE, I would like to obtain:
> ID - Cod - Type - Value - Period
> 1-COD1-AAA-100-Jan (value = 10*10)
> 2-COD2-BBB-6-Feb (value = 3*2)
> 3-COD3-AAA-6-Feb (value = 3*2)
> 4-COD4-CCC-24-Feb (value = 6*4)
> Thanks|||Thanks for help!
But If I've many fields I must to use
> value => (SELECT SUM(qt*value)
> FROM Table2
> WHERE type = Table1.type
> AND period = Table1.period);
for all fields
Thanks

Tuesday, March 20, 2012

problem with "Sysname" data type - SQL Server 2000

I have a database where several tables have fields of data
type "SYSNAME". Unfortunately SQL Server 2000 doesn't seem
to recognize this data type and this is causing "Field not
found" error messages in my application. Has anyone
encountered this problem before? How do I get around it?sysname = nvarchar(128) in 7 and 2000. It is equivalent to varchar(30) in
6.5
--
--
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"noclue6" <sobrienn@.hotmail.com> wrote in message
news:830501c350f2$3defa890$7d02280a@.phx.gbl...
> I have a database where several tables have fields of data
> type "SYSNAME". Unfortunately SQL Server 2000 doesn't seem
> to recognize this data type and this is causing "Field not
> found" error messages in my application. Has anyone
> encountered this problem before? How do I get around it?|||But its not possible to change the data type of a column
in the SYSUSERS table - i.e. a system table? Or is it?
>--Original Message--
>sysname = nvarchar(128) in 7 and 2000. It is equivalent
to varchar(30) in
>6.5
>--
>--
>Allan Mitchell (Microsoft SQL Server MVP)
>MCSE,MCDBA
>www.SQLDTS.com
>I support PASS - the definitive, global community
>for SQL Server professionals - http://www.sqlpass.org
>
>"noclue6" <sobrienn@.hotmail.com> wrote in message
>news:830501c350f2$3defa890$7d02280a@.phx.gbl...
>> I have a database where several tables have fields of
data
>> type "SYSNAME". Unfortunately SQL Server 2000 doesn't
seem
>> to recognize this data type and this is causing "Field
not
>> found" error messages in my application. Has anyone
>> encountered this problem before? How do I get around it?
>
>.
>|||You can but you most certainly do not want to.
What problems exactly are you having with it?
What are you doing at the time.?
--
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"noclue6" <sobrienn@.hotmail.com> wrote in message
news:0b1901c3510c$8a546530$a401280a@.phx.gbl...
> But its not possible to change the data type of a column
> in the SYSUSERS table - i.e. a system table? Or is it?
>
> >--Original Message--
> >sysname = nvarchar(128) in 7 and 2000. It is equivalent
> to varchar(30) in
> >6.5
> >
> >--
> >
> >--
> >Allan Mitchell (Microsoft SQL Server MVP)
> >MCSE,MCDBA
> >www.SQLDTS.com
> >I support PASS - the definitive, global community
> >for SQL Server professionals - http://www.sqlpass.org
> >
> >
> >
> >"noclue6" <sobrienn@.hotmail.com> wrote in message
> >news:830501c350f2$3defa890$7d02280a@.phx.gbl...
> >> I have a database where several tables have fields of
> data
> >> type "SYSNAME". Unfortunately SQL Server 2000 doesn't
> seem
> >> to recognize this data type and this is causing "Field
> not
> >> found" error messages in my application. Has anyone
> >> encountered this problem before? How do I get around it?
> >
> >
> >.
> >|||the software is trying to access the NAME field of the
SYSUSERS table on logon but its just not finding it
because "Name" is of type SYSNAME.
>--Original Message--
>You can but you most certainly do not want to.
>What problems exactly are you having with it?
>What are you doing at the time.?
>
>--
>--
>Allan Mitchell (Microsoft SQL Server MVP)
>MCSE,MCDBA
>www.SQLDTS.com
>I support PASS - the definitive, global community
>for SQL Server professionals - http://www.sqlpass.org
>
>"noclue6" <sobrienn@.hotmail.com> wrote in message
>news:0b1901c3510c$8a546530$a401280a@.phx.gbl...
>> But its not possible to change the data type of a column
>> in the SYSUSERS table - i.e. a system table? Or is it?
>>
>> >--Original Message--
>> >sysname = nvarchar(128) in 7 and 2000. It is
equivalent
>> to varchar(30) in
>> >6.5
>> >
>> >--
>> >
>> >--
>> >Allan Mitchell (Microsoft SQL Server MVP)
>> >MCSE,MCDBA
>> >www.SQLDTS.com
>> >I support PASS - the definitive, global community
>> >for SQL Server professionals - http://www.sqlpass.org
>> >
>> >
>> >
>> >"noclue6" <sobrienn@.hotmail.com> wrote in message
>> >news:830501c350f2$3defa890$7d02280a@.phx.gbl...
>> >> I have a database where several tables have fields of
>> data
>> >> type "SYSNAME". Unfortunately SQL Server 2000 doesn't
>> seem
>> >> to recognize this data type and this is
causing "Field
>> not
>> >> found" error messages in my application. Has anyone
>> >> encountered this problem before? How do I get around
it?
>> >
>> >
>> >.
>> >
>
>.
>

Problem while trying to login to admin

Server Error in '/' Application.

Syntax error converting character string to smalldatetime data type.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Syntax error converting character string to smalldatetime data type.

Source Error:

An unhandled exception was generated during the execution of thecurrent web request. Information regarding the origin and location ofthe exception can be identified using the exception stack trace below.


Stack Trace:

[SqlException: Syntax error converting character string to smalldatetime data type.]
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +180
LEInternational.admin.login.btnLogin_Click(Object sender, EventArgs e) in W:\le-international\admin\login.aspx.cs:87
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33

System.Web.UI.Page.ProcessRequestMain() +1292



Version Information: Microsoft .NET Framework Version:1.1.4322.2407; ASP.NET Version:1.1.4322.2407

Try to identify the T-SQL/stored proc that is causing this erros and post it here.

|||

I agree, it would help to see some code... It may be that you have some bad data in your database that won't convert to a smalldatetime. But it's impossible to know if the problem is in the stored procedure or your data without seeing the SP

Friday, March 9, 2012

problem when iserting in table

I'm building a form that collects some info from the user (user name, password and type ) and I need to store this info into a table called USER that I created.

I'm using 3 text boxes and a button, when the user clicks the button I need to collect this info and store it into my table

when i click the button i get an error msg in this line (comm.ExecuteNonQuery(); )

what do i need to do?

here is the code

protectedvoid Button1_Click(object sender,EventArgs e)

{

string str ="data source=(local);initial catalog=NH_Project1;integrated security=true;";

SqlConnection conn =newSqlConnection(str);

int rows;

SqlCommand comm =newSqlCommand("INSERT INTO [USER](UserId, UserName, UserPassword, Type)VALUES" +

"@.UsrName,@.UsrPass,@.UsrType", conn);

comm.CommandType =CommandType.Text;

comm.Parameters.AddWithValue("@.UsrName",TextBox1.Text);

comm.Parameters.AddWithValue("@.UsrPass",TextBox2.Text);

comm.Parameters.AddWithValue("@.UsrType", TextBox3.Text);

conn.Open();

rows= comm.ExecuteNonQuery();

conn.Close();

louayazar:

comm.Parameters.AddWithValue("@.UsrName",TextBox1.Text);comm.Parameters.AddWithValue("@.UsrPass",TextBox2.Text);

comm.Parameters.AddWithValue("@.UsrType", TextBox3.Text);

Remove the "@." symbol from your AddWithValue calls. Also, I'd recommend enclosing your ExecuteNonQuery call within a Try/Catch block so you can capture any errors in the future.

|||

Hii

I tried to remove the "@." like what you said but that doesn't work, I still have the same error MSG when clicking the button.

|||

Then make sure to put your ExecuteNonQuery call into a Try/Catch block and see what exception you get. This should help you find out what's going on.

|||

that was helpful, thanks a bunch

problem when insert DateTime to DataBase

the column type of stime and etime in Dabase both are datetime

------------------------------

public DateTime loginTime
{
get
{

//got user enter page's time
return DateTime.Now;
}

}

//record user's using time when user click exit button

protected void Button1_Click(object sender, EventArgs e)
{

int Member_No = Int32.Parse(cls_login2.GetCurrent_login_Member_no(this.Page));
int Lesson_No = Int32.Parse(Lesson_no);
int Prestep = 1;
string RemoteIp = Request.ServerVariables["REMOTE_ADDR"].ToString();

string sqlConn = "Insert into pro_Study_log (Member_no,Lesson_no,Study_log_stepid,Study_log_stime,Study_log_etime,Study_log_ip) ";
sqlConn += "values(" + Member_No + "," + Lesson_No + "," + Prestep + "," + loginTime + ", getdate(), '" + RemoteIp + "')";
SqlConnection connLog = new SqlConnection(StrConn);

SqlCommand cmdLog = new SqlCommand(sqlConn, connLog);
cmdLog.CommandType = CommandType.Text;
connLog.Open();
cmdLog.ExecuteNonQuery();
connLog.Close();

--------

and then I got error message on column Study_log_stime

I also trid set the dateimt tostring , still doesn't work..

I don't know where I did wrong... pleae help

many thanks

You need to put quotes around logintime. Also, I'd recommend using Parameterized Queries rather than concatenating strings. With what you have now there is a high potential for SQL Injection attacks.

|||

it's helpless if we just put quotes around logintime ( cause another error message)

problem has been resolved by use stored procedure...

thank you very much

Wednesday, March 7, 2012

Problem variable initialization

Guys I noticed that the value I set on one of the package variables is not carried over during the execution. I have a package variable of type String which I use to hold the string for a parameter in a stored procedure. My stored procedure has one output parameter which is the id of the record fetched using the string parameter. These are my parameters
1) User::vendorId Int32 Initial value = -1
2) User::vendorName String Initial value = Vendor A

I make the assignment in the Variable pane. Are there any other ways of doing this?

Watching the two variables reveals that only the value for the first variable is carried over during execution. The vendorname is always blank --> {}. I'm using a SQL Task with OLEDBConnection.

What's going on here?

Carried over during execution? What do you mean?

Is this a real problem or an issue with the diagnosis method. When watching variables, you must be on a breakpoint, and you must examine them in the watch window. Looking at the variables pane or looking when not on a breakpoint may not give you the correct value, as only the watch window at a breakpoint is updated during execution. Is a bit fussy, as you can see the value in several other windows, but they just do not get updated.

|||When you create a variable and assign it a default, that value never changes. During execution it can change, but when the package is done all variables revert back to the defaults you entered when you created the package.|||"revert back to the defaults" - think of it this way, when you execute a package the execution host loads it, then executes it and then does not save it. The execution host and the designer are two different things, albeit with some communication for the debug features. This is a change to the DTS behaviour if that is in your background.|||Guys thanks so much for th replies. I'm still in the development phase obviously and I just want the flexibility of setting values to the package variables. For this, I use the Variable pane of Visual Studio where the last column - I think - is for the default value to be used on every run. I tried to use the Script task but I couldnt find my package variables. My vendorId which is initialized to -1 retains its value during the execution; at least that's what the Watch window is showing me. The other variable User::vendorName is always blank even if I set it to a certain string value prior to F5. My control flow doesnt have any event handler. Should you need more clarification guys, I'll do everything to make this clear.
|||Just to clarify, if you change the Value property for the variable in the Variables window, save, then close and reopen the package, does it have the value you set it to? If it doesn't, make sure that you don't have a configuration set that is overwriting the variable. If the value is correct, run the package and check the value in the watch window. If it is not correct there, either an expression or a script is changing the value at runtime.|||Thanks so much. Now I remember I've tinkered about package configuration. It didn't occur to me that explains it. It's nice to see you can toggle it on/off.

I created another configuration but I can't find it in the solution explorer or in the bin table? Is the configuration available only after deployment?
|||An XML configuration will be created at whatever path you specify when you create the configuration. If you open the package configurations dialog, you should see the path to the file.

Saturday, February 25, 2012

problem using ntext data type in OPENXML

Hi,
I've got problems using ntext data in a stored procedure (SQL-Server
2000):
create procedure testproc
@.xmldata ntext
as
declare @.Param ntext
exec sp_xml_preparedocument @.idoc OUTPUT, @.xmldata
select @.Param=Param
from openxml(@.idoc, '//ROOT/Parameters')
with (
Param ntext
)
But if I pass "Param" I'll receive an internal error. If "Param" and
"@.Param" are declared as "varchar(2000)" everything works fine.
Any hints?
xpost & f'up"Tom" <me@.privacy.net> wrote in message
news:6vqit05cnuomoouvpi9279b7bl4smbbmne@.
4ax.com...
> Hi,
> I've got problems using ntext data in a stored procedure (SQL-Server
> 2000):
> create procedure testproc
> @.xmldata ntext
> as
> declare @.Param ntext
> exec sp_xml_preparedocument @.idoc OUTPUT, @.xmldata
> select @.Param=Param
> from openxml(@.idoc, '//ROOT/Parameters')
> with (
> Param ntext
> )
>
> But if I pass "Param" I'll receive an internal error. If "Param" and
> "@.Param" are declared as "varchar(2000)" everything works fine.
> Any hints?
> xpost & f'up
From a pure TSQL point of view, the obvious problem is that you cannot
declare ntext variables - see DECLARE in Books Online. I'm not sure how you
would best address this in the context of your problem, so hopefully someone
from the XML newsgroup will be able to suggest something.
Simon|||Can you use a temp table or an output parameter instead?
HTH
Michael
"Simon Hayes" <sql@.hayes.ch> wrote in message
news:41d99274$1_3@.news.bluewin.ch...
> "Tom" <me@.privacy.net> wrote in message
> news:6vqit05cnuomoouvpi9279b7bl4smbbmne@.
4ax.com...
> From a pure TSQL point of view, the obvious problem is that you cannot
> declare ntext variables - see DECLARE in Books Online. I'm not sure how
> you would best address this in the context of your problem, so hopefully
> someone from the XML newsgroup will be able to suggest something.
> Simon
>|||Tom (me@.privacy.net) writes:
> I've got problems using ntext data in a stored procedure (SQL-Server
> 2000):
> create procedure testproc
> @.xmldata ntext
> as
> declare @.Param ntext
> exec sp_xml_preparedocument @.idoc OUTPUT, @.xmldata
> select @.Param=Param
> from openxml(@.idoc, '//ROOT/Parameters')
> with (
> Param ntext
> )
>
> But if I pass "Param" I'll receive an internal error. If "Param" and
> "@.Param" are declared as "varchar(2000)" everything works fine.
If you get "Internal error", that's a bug. However, you cannot assign to
ntext parameters anyway, so you are unfortunately out of luck.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

problem using ntext data type in OPENXML

Hi,
I've got problems using ntext data in a stored procedure (SQL-Server
2000):
create procedure testproc
@.xmldata ntext
as
declare @.Paramntext
exec sp_xml_preparedocument @.idoc OUTPUT, @.xmldata
select @.Param=Param
from openxml(@.idoc, '//ROOT/Parameters')
with (
Paramntext
)
But if I pass "Param" I'll receive an internal error. If "Param" and
"@.Param" are declared as "varchar(2000)" everything works fine.
Any hints?
xpost & f'up
"Tom" <me@.privacy.net> wrote in message
news:6vqit05cnuomoouvpi9279b7bl4smbbmne@.4ax.com...
> Hi,
> I've got problems using ntext data in a stored procedure (SQL-Server
> 2000):
> create procedure testproc
> @.xmldata ntext
> as
> declare @.Param ntext
> exec sp_xml_preparedocument @.idoc OUTPUT, @.xmldata
> select @.Param=Param
> from openxml(@.idoc, '//ROOT/Parameters')
> with (
> Param ntext
> )
>
> But if I pass "Param" I'll receive an internal error. If "Param" and
> "@.Param" are declared as "varchar(2000)" everything works fine.
> Any hints?
> xpost & f'up
From a pure TSQL point of view, the obvious problem is that you cannot
declare ntext variables - see DECLARE in Books Online. I'm not sure how you
would best address this in the context of your problem, so hopefully someone
from the XML newsgroup will be able to suggest something.
Simon
|||Can you use a temp table or an output parameter instead?
HTH
Michael
"Simon Hayes" <sql@.hayes.ch> wrote in message
news:41d99274$1_3@.news.bluewin.ch...
> "Tom" <me@.privacy.net> wrote in message
> news:6vqit05cnuomoouvpi9279b7bl4smbbmne@.4ax.com...
> From a pure TSQL point of view, the obvious problem is that you cannot
> declare ntext variables - see DECLARE in Books Online. I'm not sure how
> you would best address this in the context of your problem, so hopefully
> someone from the XML newsgroup will be able to suggest something.
> Simon
>
|||Tom (me@.privacy.net) writes:
> I've got problems using ntext data in a stored procedure (SQL-Server
> 2000):
> create procedure testproc
> @.xmldata ntext
> as
> declare @.Param ntext
> exec sp_xml_preparedocument @.idoc OUTPUT, @.xmldata
> select @.Param=Param
> from openxml(@.idoc, '//ROOT/Parameters')
> with (
> Param ntext
> )
>
> But if I pass "Param" I'll receive an internal error. If "Param" and
> "@.Param" are declared as "varchar(2000)" everything works fine.
If you get "Internal error", that's a bug. However, you cannot assign to
ntext parameters anyway, so you are unfortunately out of luck.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Monday, February 20, 2012

Problem using dates in XMLtoFLFF Transformation

I am having a bit of trouble transforming a XML (xs:date) type to the DBDATE in my FLFF. I believe the problem is because the SSIS DF (Metadeta) converts xs:date to DT_DBTIMESTAMP which becomes 01/01/2005 00:00:00 -- appending the time. So when I try to transform in my fixed length flat file, it throws a truncation error when the length is set to 10. (which is the length of date)

Is it possible to (A) use some other xs format that changes DF Metadata to only use date and not DT_DBTIMESTAMP, or (B) is there a field type in the destination FLFF Connection that will allow a length of 10 without throwing a truncation error?The only output column date type supported by the XmlSrc is DT_DBTIMESTAMP. You could try changing the output column type to a string in the advanced editor, and set it to the length you want, and set the truncation disposition to ignore truncations.

Or, You could place a Data Conversion transform on the output of the XmlSrc, and either convert the DT_DBTIMESTAMP column to DT_DBDATE (which does not include the time), or actually convert the DT_DBTIMESTAMP to a string of the desired length and set the truncation disposition to ignore truncations.

Let me know if this solves your problem, or you need a different solution.

Mark|||Thanks Mark the feedback. Yep, I ended up implementing the first solution and works ok. The second solution is a good one as well but seems a bit too much, we will just enforce no date_type validations for now. Do you (or anyone else) know if this ability will ever be natively incorporated into SSIS?|||Do you mean, will it be possible to map the xml input to a date type other than just DT_DBTIMESTAMP directly in the XmlSrc adapter? If so, I know of no plans for that, but it would be great if you could open a DCR bug to that effect.