Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Thursday, March 22, 2012

Default cursor in SQL 2000

Hello,

I am writing an application which I would like to use a server cursor on. I have noticed that when I try to access a table that I have created using a server cursor with my app, I have problems getting the information. It says that the cursor doesn't support bookmarks. But, when I access the Employees table on the Northwind database with the same settings, everything is fine. Is there some sort of option I'm missing with my tables? Some default cursor or something? Is there a way to tell what cursors are defined with the Northwind DB? Any help would be great, thanks!Check if your table has a primary key|||that was it, thank you very much!

Originally posted by kukuk
Check if your table has a primary key|||Would something similar also go for the dynamic cursor? I setup the primary keys which works great for Keyset type. But I get the old 'Dataset does not support bookmarks' when trying a dynamic cursor on the same dataset. I've tried both MSDASQL and SQLOLEDB providers, both gave errors.

Originally posted by Thread77
that was it, thank you very much!sql

Default charset in sqlserver 2000? / jtds

Hi,

I am writing to a text column in my SQL Server 2000 database. The text
comes from a web form in my java web application, where the character
encoding is ISO-8859-1. (I have no control over the charset, my app is
a plugin inside another app.)
Characters such as (ascii 128) and '(ascii 146) are inserted into
the db as '?'.

I'm connecting using the free jtds driver, and I'm not specifying any
details about charsets in my usage of the driver.

Can anyone tell me what the default charset in sqlserver 2000 is?
Should I be specifying this charset when using my driver?
Thanks.downlode@.gmail.com wrote:
> Hi,
> I am writing to a text column in my SQL Server 2000 database. The text
> comes from a web form in my java web application, where the character
> encoding is ISO-8859-1. (I have no control over the charset, my app is
> a plugin inside another app.)
> Characters such as (ascii 128) and '(ascii 146) are inserted into
> the db as '?'.
> I'm connecting using the free jtds driver, and I'm not specifying any
> details about charsets in my usage of the driver.
> Can anyone tell me what the default charset in sqlserver 2000 is?
> Should I be specifying this charset when using my driver?
> Thanks.

You probably want to use ntext instead of text, nvarchar instead of
varchar, etc.|||(downlode@.gmail.com) writes:
> I am writing to a text column in my SQL Server 2000 database. The text
> comes from a web form in my java web application, where the character
> encoding is ISO-8859-1. (I have no control over the charset, my app is
> a plugin inside another app.)
> Characters such as ?(ascii 128) and '(ascii 146) are inserted into
> the db as '?'.

Hm, in iso-8859-1, the slots 128-159 not graphic characters. In Windows-
1252, Microsoft's extension of 8859-1, some of them are indeed graphic.

> I'm connecting using the free jtds driver, and I'm not specifying any
> details about charsets in my usage of the driver.
> Can anyone tell me what the default charset in sqlserver 2000 is?

No, because this depends on the regional settings of the machine. For
instance, if I install SQL Server on my machine, and do not make any
selection, I will get Finnish_Swedish_CI_AS, which implies code page
1252. People in Poland are likely to get Polish_CI_AS, which implies
code page 1250. And that's only the default. This can be overridden
at installation. And then the collation can be set independently by
column.

So start doing

SELECT serverproperty('Collation') -- Server default collation.
SELECT databasepropertyex('db', 'Collation') -- Database default

And then use sp_help to determine the coilations of the columns you
are working with. If you don't know which code page a certain collation
has, there is a function Collationproperty() for this.

If the columns are of different code pages, you will have to use
Unicode somewhere on the way, and as Trevor said, ntext nvarchar are
probably better options.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Hi,
sorry for the late follow up to this.
My database has the same collation throughout -
SQL_Latin1_General_CP1_CI_AS
The columns share this collation.
Even when I use a preparedStatement, ensuring that the outgoing text is
treated as Unicode by the free jtds driver, I get the same problems.

I am stumped by this one.

If I change my text column to an ntext column, will this affect the
existing entries?
Thanks,
Mike|||(downlode@.gmail.com) writes:
> sorry for the late follow up to this.
> My database has the same collation throughout -
> SQL_Latin1_General_CP1_CI_AS
> The columns share this collation.
> Even when I use a preparedStatement, ensuring that the outgoing text is
> treated as Unicode by the free jtds driver, I get the same problems.
> I am stumped by this one.

Since SQL_Latin1_General_CP1_CI_AS is share code page with iso-8859-1,
it's indeed a little funny. But as I noted in my previous post, the
characters you have problem with are not in iso-8859-1 - these code
points are control characters to 8859-1. In Windows Latin-1 they are
indeed printable characters.

My guess is that the free jtds takes a strict definiton of what is
8859-1. But I don't it, so you should inquire in a forum for that driver.

> If I change my text column to an ntext column, will this affect the
> existing entries?

No.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspxsql

Friday, March 9, 2012

Decimal value is getting rounded

I am writing a simple shopping cart app and the price field is being rounded when inserted into the database.
There is a textbox for the user to enter the price. A stored procedure is used to insert the line item info to the data base table. The field in the table is formatted as datatype decimal. Below is the stored procedure and the code that adds the value to the parameter. Any suggestions on where I am going wrong?
<Code>
CREATE PROCEDURE [sp_insert_CartDetail]
(
@.ReferenceNum [int],
@.Item [varchar](26),
@.Desc1 [varchar](27),
@.Desc2 [varchar](20),
@.Desc3 [varchar](30),
@.Desc4 [varchar](30),
@.Note [text],
@.Quantity [int],
@.DateOrdered [datetime],
@.SalesPrice [decimal],
@.DistCost [decimal],
@.SalesTaxable [smallint],
@.RequiredDate [datetime],
@.User1 [varchar](12),
@.User2 [varchar](12),
@.User3 [varchar](12),
@.User4 [varchar](12),
@.User5 [varchar](12),
@.User6 [varchar](12))

AS INSERT INTO [ToolCrib].[dbo].[CartDetail]
(
[ReferenceNum],
[Item],
[Desc1],
[Desc2],
[Desc3],
[Desc4],
[Note],
[Quantity],
[DateOrdered],
[SalesPrice],
[DistCost],
[SalesTaxable],
[RequiredDate],
[User1],
[User2],
[User3],
[User4],
[User5],
[User6])

VALUES
(
@.ReferenceNum,
@.Item,
@.Desc1,
@.Desc2,
@.Desc3,
@.Desc4,
@.Note,
@.Quantity,
@.DateOrdered,
@.SalesPrice,
@.DistCost,
@.SalesTaxable,
@.RequiredDate,
@.User1,
@.User2,
@.User3,
@.User4,
@.User5,
@.User6)
SqlCmdInsetCartDetail.Parameters("@.SalesPrice").Value =CType(txtCost.Text,Decimal)

</code>

Does the table field have precision and scale set for the decimal type? You'd want to set them also for decimal type parameters.|||db table has precision of 18 and scale of 0. What should it be set to if I want decimal to 4 places. Is decimal the correct data type for this situation?
Thanks,
Danny|||Try this link for code to set the precision and scale in .NET. Hope this helps.
http://support.microsoft.com/?kbid=892406|||I have set the scale to 4 on both the data table and the parameters... No change
Caddre, I don't think that pertains to my situation. 1 - I am running this on MSSQL7. 2-I am not returning a value from the sproc.
|||In SQL Server 7.0 change the data type to Numeric it is more stable in SQL Server 7.0 than Decimal because I remember when Money was rounding to less than one dollar in 1999 the only fix was with Numeric. And set the precision and scale, why I think it comes from TDS(tabular data stream) 7.0. Hope this helps.

Saturday, February 25, 2012

Deciding between Access and MSDE

We are a small company writing primarily in-house
software, but also potentially developing software to
market.
We are converting from writing all of our software
completely in Access to writing in Visual Studio (C#). We
are confident this the best decision for both our in-house
and potentially marketable software.
What is a bit of a question mark is whether it is best to
go with Access/Jet databases (questionable since MS has
deprecated the Jet engine and is not upgrading anymore) or
MSDE. My feeling is that for future functionality and
scalablity MSDE (SQL Express 2005 when it comes out of
Beta and we upgrade to .NET 2.0) is a better choice.
Here are my concerns:
1) How common is it to hit the 2GB per database limit?
That sounds very large to me and seems unlikely to be a
problem except in extremely large applications. We are not
storing pictures or documents, only standard data types
(text, int, bool).
2) In the 2GB data structure, is there any reason I can't
have an archive database to move old data into to keep the
size of the working database down if necessary?
3) From a deployability standpoint, Access is a breeze.
Copy a file to wherever you want it and point to it. Is
there a way to build easy deployment of MSDE into our core
application so there is minimal effort (choosing a
directory or location, even if installed on a server) on
the part of the end user?
Thanks,
Dan
dan@.builtbydan.com
> 1) How common is it to hit the 2GB per database limit?
> That sounds very large to me and seems unlikely to be a
> problem except in extremely large applications. We are not
> storing pictures or documents, only standard data types
> (text, int, bool).
That depends on you workload and structure, its hard to say, but for a
normal application
it will fit your needs. It it wont, its no proble to upgrade your db to SQL
Server 2000, or to the SQL Server Express database which woont have this 2
GB Limit at all.

> 2) In the 2GB data structure, is there any reason I can't
> have an archive database to move old data into to keep the
> size of the working database down if necessary?
Yeah could be a choice, but i rather sould store all data in one database as
long as the size will allow.

> 3) From a deployability standpoint, Access is a breeze.
> Copy a file to wherever you want it and point to it. Is
> there a way to build easy deployment of MSDE into our core
> application so there is minimal effort (choosing a
> directory or location, even if installed on a server) on
> the part of the end user?
MSDE doenst cost that much CPU time that you cannot install it on a file
server or a workstation. So installing the MSDE on very other workstation,
detach /Attach the db file and switch over your application settings to the
new storage isnt a hassle.
HTH, Jens Smeyer.
http://www.sqlserver2005.de
"Dan Fontenot" <dan@.builtbydan.com> schrieb im Newsbeitrag
news:059301c545c6$fc6e10c0$a401280a@.phx.gbl...
> We are a small company writing primarily in-house
> software, but also potentially developing software to
> market.
> We are converting from writing all of our software
> completely in Access to writing in Visual Studio (C#). We
> are confident this the best decision for both our in-house
> and potentially marketable software.
> What is a bit of a question mark is whether it is best to
> go with Access/Jet databases (questionable since MS has
> deprecated the Jet engine and is not upgrading anymore) or
> MSDE. My feeling is that for future functionality and
> scalablity MSDE (SQL Express 2005 when it comes out of
> Beta and we upgrade to .NET 2.0) is a better choice.
> Here are my concerns:
> 1) How common is it to hit the 2GB per database limit?
> That sounds very large to me and seems unlikely to be a
> problem except in extremely large applications. We are not
> storing pictures or documents, only standard data types
> (text, int, bool).
> 2) In the 2GB data structure, is there any reason I can't
> have an archive database to move old data into to keep the
> size of the working database down if necessary?
> 3) From a deployability standpoint, Access is a breeze.
> Copy a file to wherever you want it and point to it. Is
> there a way to build easy deployment of MSDE into our core
> application so there is minimal effort (choosing a
> directory or location, even if installed on a server) on
> the part of the end user?
> Thanks,
> Dan
> dan@.builtbydan.com
|||hi Dan,
Dan Fontenot wrote:
> Here are my concerns:
> 1) How common is it to hit the 2GB per database limit?
> That sounds very large to me and seems unlikely to be a
> problem except in extremely large applications. We are not
> storing pictures or documents, only standard data types
> (text, int, bool).
personally I never hit that limit with "standard" data type, but this depend
on the customer's needs...

> 2) In the 2GB data structure, is there any reason I can't
> have an archive database to move old data into to keep the
> size of the working database down if necessary?
nope... you can go for that design implementig a sort of partitioning...
something called vertical partitioning like, where all columns relatated to
a particular object model are stored in one database and are not related to
objects in the other one..
but this has little to do with other performance tuning including
partitioned servers and federated database...

> 3) From a deployability standpoint, Access is a breeze.
> Copy a file to wherever you want it and point to it. Is
> there a way to build easy deployment of MSDE into our core
> application so there is minimal effort (choosing a
> directory or location, even if installed on a server) on
> the part of the end user?
yes, distributing JET database really is a breeze, but you can have simple
deployment scenarios like
http://msdn.microsoft.com/msdnmag/is...baseinstaller/ ,
and you can easily use the default SQL Server data path (..\Program
Files\Microsoft SQL Server\MSSQL\Data [for a default instance]) or specify
custom target prosition, both at MSDE installtime, using the DATADIR
parameter
(http://msdn.microsoft.com/library/de...stsql_84xl.asp),
valid for all databases, or at runtime, specifying specific path in the
CREATE DATABASE statement
(http://msdn.microsoft.com/library/de...reate_1up1.asp)...
usually the database folder should not be shared among "standard" Windows
users for security reasons, but you can actually put them wherever you want
as long as the Windows account running SQL Server service is able to reach
them...
in SQL Express scenario, you have further options, where you can take
advantage of a so called "Application XCopy"
http://msdn.microsoft.com/library/?u...seoverview.asp ,
partially available in SQL Server 2000 too via the sp_attach_db method
(http://msdn.microsoft.com/library/de...ae-az_52oy.asp)...
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.11.1 - DbaMgr ver 0.57.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply

Debugging tool for SP

After writing a Stored Procedure(which is giving correct reasult) how can I go for optimizing it?Is there any tool to debug a stored procedure?You should optimize the sql statements _before_ creating the sp.

Sunday, February 19, 2012

Debugging acting weird

Hi!
I have VS2005 RC1 and SQL Server 2005 September CTP installed on the same machine.
I'm writing some pretty simple C# stored procedures and I'd like to be able to debug them with with the VS2005 IDE. However, something's not working.
When I set a breakpoint and I run the code (F5), it turns white with a red border informing me that "the breakpoint will not currently be hit. No symbols have been loaded for this document". Obviously, those breakpoints are not hit and I cannot debug exceptions either.
I made sure the connection the project is linked to has "ApplicationDebugging" and "Allow SQL/CLR Debugging" turned on.
I'm probably missing a very simple step to get this working, but Google didn't help me this time. So that's why I come here begging for your help! Big Smile
Thanks in advance!
Carl

Hi Carl,

Have you executed the following TSQL code to enable SQLCLR on the server?

Create a new Stored Procedure in VS, then add the following:

exec sp_configure 'clr enabled',1
reconfigure

If this doesnt work, could you answer the following questions:

1, Are you the running as the machine admin?
2, Are you able to debug a regular TSQL Stored Procedure?
3, Could you send me the text from the output window.

Thanks

Richard Cook
VS SQL Debugger QA

Debugging acting weird

Hi!
I have VS2005 RC1 and SQL Server 2005 September CTP installed on the same machine.
I'm writing some pretty simple C# stored procedures and I'd like to be able to debug them with with the VS2005 IDE. However, something's not working.
When I set a breakpoint and I run the code (F5), it turns white with a red border informing me that "the breakpoint will not currently be hit. No symbols have been loaded for this document". Obviously, those breakpoints are not hit and I cannot debug exceptions either.
I made sure the connection the project is linked to has "ApplicationDebugging" and "Allow SQL/CLR Debugging" turned on.
I'm probably missing a very simple step to get this working, but Google didn't help me this time. So that's why I come here begging for your help! Big Smile
Thanks in advance!
Carl

Hi Carl,

Have you executed the following TSQL code to enable SQLCLR on the server?

Create a new Stored Procedure in VS, then add the following:

exec sp_configure 'clr enabled',1
reconfigure

If this doesnt work, could you answer the following questions:

1, Are you the running as the machine admin?
2, Are you able to debug a regular TSQL Stored Procedure?
3, Could you send me the text from the output window.

Thanks

Richard Cook
VS SQL Debugger QA

Debugging a worker thread inside SQL Server

Hi Everyone!

Just started looking into Assemblies within SQL Server in the hope of creating a multi-threaded application and when writing a basic test assembly I came across the following problem...

When I create a worker thread within my assembly I am unable to do the following in my newly created thread:

Stop on a breakpoint in VS2005 Use Debug.Writeline to output to the output window

I know the thread is running as I am able to write to the EventLog, but VS2005 seems to be unaware of any thread other than the main SQL server thread.

If anyone could tell me whether there it is possible to debug non-SQL server threads, whether I am doing something wrong, or whether I should be doing things differently that would be great!

Thanks in advance for any help!!

The code is as follows (apologies as its not very well written!):

using System;

using System.Data;

using System.Data.SqlClient;

using System.Data.SqlTypes;

using Microsoft.SqlServer.Server;

using System.Threading;

using System.Diagnostics;

public partial class StoredProcedures

{

/// <summary>

/// This stored procedure starts the comms

/// </summary>

[Microsoft.SqlServer.Server.SqlProcedure]

public static void StartComms()

{

try

{

// Output some debug output to show the thread is running

Debug.WriteLine("Comms is starting");

// Create the thread to run in the main thread class

Thread zThread = new Thread(new ThreadStart(ThreadFunction));

// Start the thread running

zThread.Start();

// Sleep to let the other one run

Thread.Sleep(2000);

// Output some debug output to show the thread is running

Debug.WriteLine("Comms is about to wait for thread to finish");

// Wait for the thread to complete

zThread.Join();

// Output some debug output to show the thread is running

Debug.WriteLine("Comms is ending");

}

catch

{

throw;

}

}

/// <summary>

/// The main thread function

/// </summary>

public static void ThreadFunction()

{

try

{

// Flag to keep thread running

bool bRunning = true;

// While the thread is running

while (bRunning == true)

{

// Output some debug output to show the thread is running

Debug.WriteLine("Thread function running");

System.Diagnostics.EventLog.WriteEntry("SQLServerThreadTest",

"Thread function is running");

// Sleep for two seconds

Thread.Sleep(5000);

}

}

catch

{

throw;

}

}

};

If you start debugging by doing "Attach to Process" and selecting sqlservr.exe before executing your proc then the breakpoint is hit and Debug.Writeline does work in VS as expected.

I've forwarded this thread to the VS guys to see why your bp is not being hit when you start debugging either from a t-sql debug script or by doing "Step Into" your stored procedure.

Steven

|||

Hi Steven!

Thanks very much for your response.

I have tried out the "Attach to Process" this morning and by debugging this way everything works as expected - a treat!

If you find out any more information from the VS guys if you could post that for me that would be great, although I am very happy just knowing that there is a way to debug the application that I am going to write.

Thank you very much again for your help!!