|
If you're using Jet 4 / Access 2000, you can use SELECT @@IDENTITY to return the value.
|
|
|
|
|
Stupid question, but I haven't used MSDE before. Here goes, I have MSDE located at:
\\MyPCName\MSDE
or
\\MyPCName\NetSDK
All the examples of ADO.NET use a connection string with:
server=localhost
How do I configure my system to locate the db at localhost?
Cheers
|
|
|
|
|
'\\MyPCName\MSDE' would seem to indicate a network share path, whereas 'localhost' will resolve to the IP address 127.0.0.1
From the little bit of work I've done with SQL Server (as I understand it, MSDE is a mini SQL Server), there are a couple different communication/transport mechanisms it can use. One is TCP/IP, which would use an IP address to connect, and another is using Named Pipes, which would use the netbios-style shares like '\\MyPCName\MSDE'.
I'm guessing that the ADO.NET samples are connecting to the MSDE via TCP/IP, which is why they specify 'localhost' as the server parameter. Poke around in the MSDE settings and see if it mentions anything about being able to communicate to DB clients via TCP/IP...
Sorry I can't be of more help - but it's been years since I fiddled with SQL Server, and I've never even touched MSDE...
--
Russell Morris
"Have you gone mad Frink? Put down that science pole!"
|
|
|
|
|
The connection string for SQL Server/MSDE is typically
Provider=SQLOLEDB;Server=MyPCName;Database=yourdbname;UID=??;PWD=??;
You can omit the Database= bit and it defaults to the default db for the given user.
The MyPCName can be either a machine name or a dotted IP address.
As long as you have the SQL/MSDE client installed (usually via MDAC) it all works quite well.
Steve S
[This signature space available for rent]
|
|
|
|
|
Hi,
Is it possible to use table variables as parameters to a stored procedure?
What i would like to do is:
CREATE PROCEDURE [dbo].[spSetBillingPlan_Custom]
@ContractNumber integer,
@ArgTable TABLE(phasenum integer, perc decimal(5,4))
AS
--yadda yadda yadda
But it doesnt seem to like the table arguement.
If it is not possible, can anyone offer an alternative solution to passing a variable amount of data to a stored proceedure?
Thanks and Regards,
Alex
|
|
|
|
|
This code came from one of the SQL Server sites:
CREATE FUNCTION fn_Split
(
@sText varchar(8000),
@sDelim varchar(20) = ' '
)
RETURNS @retArray TABLE
(
idx smallint Primary Key,
value varchar(8000)
)
AS
BEGIN
DECLARE @idx smallint,
@value varchar(8000),
@bcontinue bit,
@iStrike smallint,
@iDelimlength tinyint
SELECT
@idx = 0,
@bContinue = 1,
@sText = LTrim(RTrim(@sText)),
@iDelimLength = CASE
WHEN @sDelim Is Null THEN 0
WHEN @sDelim = 'Empty' THEN 0
WHEN @sDelim = 'Space' THEN 1
ELSE DataLength(@sDelim)
END,
@sDelim = CASE
WHEN @sDelim Is Null THEN ''
WHEN @sDelim = 'Empty' THEN ''
WHEN @sDelim = 'Space' THEN ' '
ELSE @sDelim
END
IF NOT (@iDelimlength = 0)
BEGIN
WHILE @bcontinue = 1
BEGIN
--If you can find the delimiter in the text, retrieve the first element and
--insert it with its index into the return table.
IF CHARINDEX(@sDelim, @sText)>0
BEGIN
SET @value = LTrim(RTrim(SUBSTRING(@sText,1,CHARINDEX(@sDelim,@sText)-1)))
INSERT INTO @retArray (idx, value)
VALUES (@idx, @value)
--Trim the element and its delimiter from the front of the string.
--Increment the index and loop.
SELECT
@idx = @idx + 1,
@iStrike = DATALENGTH(@value) + @iDelimlength,
@sText = LTrim(RTrim(Right(@sText,DATALENGTH(@sText) - @iStrike)))
END
ELSE
BEGIN
--If you can’t find the delimiter in the text, @sText is the last value in
--@retArray.
SET @value = LTrim(RTrim(@sText))
INSERT INTO @retArray (idx, value)
VALUES (@idx, @value)
--Exit the WHILE loop.
SET @bcontinue = 0
END
END
END
ELSE
BEGIN
WHILE @bcontinue=1
BEGIN
--If the delimiter is an empty string, check for remaining text
--instead of a delimiter. Insert the first character into the
--retArray table. Trim the character from the front of the string.
--Increment the index and loop.
IF DATALENGTH(@sText)>1
BEGIN
SET @value = SUBSTRING(@sText,1,1)
INSERT INTO @retArray (idx, value)
VALUES (@idx, @value)
SELECT
@idx = @idx+1,
@sText = SUBSTRING(@sText,2,DATALENGTH(@sText)-1)
END
ELSE
BEGIN
--One character remains.
--Insert the character, and exit the WHILE loop.
INSERT INTO @retArray (idx, value)
VALUES (@idx, @sText)
SET @bcontinue = 0
END
END
END
RETURN
END
You can pass a list of values separated by commas to your proc, call this function to get a table, and then cast the table values to the type you need. E.g.:
Create Proc dbo.spSetBillingPlan_Custom
(
@ContractNumber int,
@PhaseNum varchar(8000),
@Perc varchar(8000)
)
As
DECLARE @ArgTable TABLE(PhaseNum int, Perc decimal(5,4))
INSERT INTO
@ArgTable (PhaseNum, Perc)
SELECT
CAST(PhaseNum.value As int),
CAST(Perc.value As decimal(5,4))
FROM
dbo.fn_Split(@PhaseNum, ',') As PhaseNum
INNER JOIN
dbo.fn_Split(@Perc, ',') As Perc
On PhaseNum.idx = Perc.idx
--yadda yadda yadda
|
|
|
|
|
As you have correctly pointed out. SQL Server 2000 doesn't allow table variables as input parameters in stored procedures.
What you could use instead is the "politically correct" xml document. Pass an xml document (array... ) to the SQL Server, and use the OPENXML statement to process it.
Morty
|
|
|
|
|
.. anyone know what it is?
I thought it was nvarchar but I cant get it to go higher than 4000.
|
|
|
|
|
Ray Cassick wrote:
.. anyone know what it is?
I thought it was nvarchar but I cant get it to go higher than 4000.
Text.
But be warned the Text data type can be an utter pain in the neck. My recommendation is to put it as the last field in a table and then sacrifice a virgin to the SQL god on the slopes of Mount Kiloquery.
Also it is a pain to edit a Text field within QA or Enterprise Manager. Generally Text fields suck IMO.
|
|
|
|
|
Paul Watson wrote:
Also it is a pain to edit a Text field within QA or Enterprise Manager. Generally Text fields suck IMO
How so? other than the fact that it potentially contains a lot of data?
Signature space for rent. Apply by email to....
|
|
|
|
|
Jon Hulatt wrote:
How so? other than the fact that it potentially contains a lot of data?
Well hopefully you can prove me wrong but when in Enterprise Manager it cuts off the value after a certain length in the display (the data is still there naturally, just that it does not show it all. Copy and paste also does not work.) Same with QA, it returns a delimited set of that field.
The only way I can ever edit those text fields and retain a lot of data is by using some ASP and a recordset to input and output. Is there a better way?
|
|
|
|
|
Tools -> Options -> Results -> Maximum Characters per column. I was chuffed when i found that too.
Signature space for rent. Apply by email to....
|
|
|
|
|
I had looked at the text type, but was confused because when I added it, the maximum I could set the size for was 16. I asume that it ends up being a type of record pointer so it only needs that size, but it looks really confusing.
I am looking at writing an ASP.NET message area using SQL and need a data type for the messages. I know that 8000 would probably be ok, but.....
|
|
|
|
|
Ray Cassick wrote:
when I added it, the maximum I could set the size for was 16. I asume that it ends up being a type of record pointer so it only needs that size, but it looks really confusing.
Honestly I do not know the max of the Text field but we have stored a helluva lot in it before with no problem (way, way, way more than 8000chars.)
So it should be fine for your use, just be careful
|
|
|
|
|
FYI, text is indeed a reference field. It is 16 bytes in size, because the data is stored outside of a row.
The net result of this is that:- conditions involving text fields are slower than a varchar would be, and many of the T-SQL functions cannot operate on text.
SQL Server supports max row size of 8192 (IIRC) bytes, and after some internal overhead this leaves 8060 (IIRC) bytes for user columns. Varchars max size is 8000 bytes. So you could not have two varchar(8000) columns in one table.
Incidentally, in your original post, you mention nvarchar. nvarchar is simply a wide character version of varchar, and as such takes twice the storage space of a varchar, thus explaining the max size of 4000 characters.
hope that clears some stuff up.
Signature space for rent. Apply by email to....
|
|
|
|
|
So what exactly is the difference between text and ntext then?
|
|
|
|
|
ntext is a wide character text.
Signature space for rent. Apply by email to....
|
|
|
|
|
Hello everyone,
When I install the MS SQLServer, I can choose the comparison method of the default instance whether is case sensitive. Can I change the character comparison method of a existed instance.
Thanks.
Kerry Chou (STU)
|
|
|
|
|
I don't know if you can change the entire DB to be case sensitive, but you can apply case sesitivity to a specific column or table.
Read up on collations in sql server documentation. But for now, have a look at this example:-
CREATE TABLE [CaseSense] (
[ColA] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CS_AS NULL ,
[ColB] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CS_AS NULL
) ON [PRIMARY]
insert into CaseSense values ('aaaa','aaaa')
insert into CaseSense values ('bbbb','BBBB')
--then
select * from casesense where cola=colb
-- will return the first record
select * from casesense where not cola=colb
-- will return the other one.
Signature space for rent. Apply by email to....
|
|
|
|
|
In SQL Server 2000 you can collate when selecting objects.
Example of case sensitive compare on case-insensitive database:
<br />
SELECT table1.name COLLATE SQL_Latin1_General_CP1_CS_AS <br />
FROM table1<br />
WHERE table1.name NOT IN<br />
(SELECT table2.name COLLATE SQL_Latin1_General_CP1_CS_AS FROM table2)<br />
|
|
|
|
|
ACCESS2000, ADO with VC++
I need to insert 500 records into a table. I am executing the following query for each record in a loop..
/////////////
PARAMETERS vID Short, vMRad IEEESingle, vQual Byte, vType Byte, vCRad IEEESingle, vWID Long;
INSERT INTO PostODData ( OID, MRad, Qual, Type, CRad, WID )
VALUES (vID, vMRad, vQual, vType, vCRad, vWID);
//////////////////
This insertion takes about 5 secs on a 400Mhz computer and I need to cut the time down to 1 sec or smaller.
Any suggestions how to improve. Is it possible to send the parameters for all 500 records in an array . Does it help ?
Thanks
|
|
|
|
|
|
You could use the XML version IXmlBulkLoad (?) found in one of the SqlXml releases for SQL Server 2000. It would give you a more "programmable" approach.
You could also use the native OLEDB interface (used by BCP ? ) IRowsetFastLoad. (look it up in the SQLOLEDB specs.)
Morty
|
|
|
|
|
I don't know about ADO but in DAO it was significantly faster to use a recordset's AddNew/Update methods to insert records than INSERT statement.
Pavel
Sonork 100.15206
|
|
|
|
|
1. How do I turn off the confirmation warnings when executing action queries
and deleting records from VBA code in MS Access 2000?
2. How do I call a VBA routine at startup of the MDB?
|
|
|
|
|