Ultra Newbie - Primary Key And STORAGE

Aug 14, 2006

I'm trying to learn SQL with SAMS Teach Yourself SQL in 24 hours and using SQL 2000 Server but because the book is a generic SQL code I'm finding some of the examples don't work for me. Firstly is there a STORAGE command in MS SQL as when I tried to create my table and appended:

STORAGE
(INITIAL 20M
NEXT 1M);


All I got was an error and couldn't figure how to get round it.

Secondly, I created my table via:

CREATE TABLE TBL_EMPLOYEE
(EMP_IDCHAR(9)NOT NULL,
EMP_NAMEVARCHAR(40)NOT NULL,
EMP_ST_ADDRVARCHAR(20)NOT NULL,
EMP_CITYVARCHAR(15)NOT NULL,
EMP_STCHAR(2)NOT NULL,
EMP_ZIPINTEGERNOT NULL,
EMP_PHONEINTEGERNULL,
EMP_PAGERINTEGERNULL);


but can't figure out how to now add a Primary Key. I added a line to my QA window:

ALTER TABLE TBL_EMPLOYEE ADD CONSTRAINT EMP_ID PRIMARY KEY;


And when I parse it, it says it complete's successfully but then when I try and execute it errors.

Can you see what I'm doing wrong / should I give up now?

Thanks

View 7 Replies


ADVERTISEMENT

Reducing Storage Space By Moving Rarely Required Columns To Separate Table While Sharing Primary Key Constraint

Aug 17, 2006

Dear all,

In my current database design, there is one table (PState) which has a Primary Key (int) and a few other fields.

During development, a pattern started to arise; for certain rows in PState, I wanted to specify an additional set of columns (over 10 of them with quite large lengths) for each row in PState. However, as these additional columns would only be required in approximately 20% of the rows of PState, there would be plenty of NULL values in PState if I would make this table wider than necessary. So, I decided to create a separate table with those optional columns (PStateWFI). In order to attach these additional columns in PStateWFI to PState in the cases they were needed, I would obviously have to create a Foreign Key constraint on the Primary Key of PStateWFI so that these optional rows would know which row in PState they would belong to.

However, the problem with this approach is that one could define multiple rows in PStateWFI referring to the same row in PState, which would not make sense. Thus, a UNIQUE index constraint added to the constrained ID column in PStateWFI would make sense to ensure that there could only be one set of optional columns added to each row in PState. But now, when adding the UNIQUE index, the FK constraint started to appear as a bidirectional key link in the Diagram; hence, new entries in PState would have to meet a FK constraint based on PStateWFI, which was not intended.

Hence, I had to create a quite awkward design to enforce the constraints:

1. The PState table has a Primary Key (PState.ParticleID, int, Identity Specification: Yes)
2. The PStateWFI table has a Primary Key (PstateWFIID, int, Identity Specification: Yes)
3. PStateWFI has field "PStateID" which has a FK constraint to PState.ParticleID (which is a one-way constraint operating in the correct way and does not constrain insertions in PState)
4. PStateWFI has an additional column ParticleIDIndex which has a UNIQUE Index attached to it.
5. There is a check constraint on PStateWFI enforcing PStateWFI.ParticleIDIndex = PStateWFI.ParticleID.

Although this structure does the job, it makes it necessary to add a redundant column in PStateWFI by duplicating the PStateWFI.ParticleID into PStateWFI.ParticleIDIndex, since I can't create a UNIQUE index on PStateWFI.ParticleID without constraining the PState table as well. So, insertions into this table would have to insert the same value into two columns. Not a big deal, but appears slightly ugly.

Basically I'd hope someone could explain why a bidirectional FK constraint has to be enforced on the primary key table in a relationship when the constrained column in the primary key table has a UNIQUE index attached on it. I have a few other cases where the above approach would benefit from a more clear structure.

Thanks in advance for any advice.

View 6 Replies View Related

One Table Is Ultra Slow At Being Copied, Others Are Fine

Jun 10, 2007

This is a really really odd problem.

Here's the situation. I've got a DB with several tables. Let's pick out two of those tables from the bunch.. they both have approx 2500 rows in them. I take one and duplicate it (right click, All Tasks->Export Data, copy tables, etc) and it duplicates just fine into another DB.

Now, the second table.. takes FOREVER. Yet it has the same amount of rows in it! And this is a flat table export.. I'm not including dependent objects or anything like that.

Not to mention this is slow, but when I use Red-Gate SQL Data Compare, it gets stuck when it hits this specific table.

Anyone have any idea what would cause this?

View 3 Replies View Related

SQL 2012 :: Distinct Storage Tier Of Remote BLOB Storage (RBS)

Oct 27, 2014

How to implement distinct storage tiers on SQL Remote BLOB Storage (RBS)?

I want to use this SQL Feature to move files(images, videos, pdf files) from a database to a distinct database dedicated to RBS. Then I want to have several storage tiers, where objects will be saved and moved according access frequency. Old data will be arquived in cheap storage, but it must be always accessible if needed.

Description:
- 1st and main tier: new and frequently accessed objects stored in high performance storage;
- 2nd tier: automatically move older or less accessed objects to an inexpensive and different storage tier;
- in all cases, all objects must be accessible to all users, but accessing to archived objects(2nd tier) will be much slower;

View 0 Replies View Related

Can't Install IBM Tivoli Storage Manager Server On Windows 2003 X64 Storage Server, How Can I Fix The Pkg?

Jan 14, 2008

I am a Windows developer for the IBM Tivoli Storage Manager Server (TSMS) product.
Our product installation is built with InstallShield and uses the Windows Installer.

On a new installation of Windows 2003 x64 Storage Server R2, at a customer's site, the TSMS product fails to install.
The install of the OS has version 3.01.400.3959 of the Windows Installer and I see no newer version that installs.

Part of our product is 32 bit (console) and another part is x64 (server).
When installing I can see that the install's default is being redirected/reset to C:Program Files (x86)TivoliTSM after it is explicitly set by a custom action to ..Program Files.. . I further observe that our custom actions to write 64 bit registry entries are being refused.

REGSAM samMask = KEY_ALL_ACCESS;
if ( regIsWow64Process () ) samMask = samMask | KEY_WOW64_64KEY;
lStatus = RegCreateKeyEx( hLocalConnectKeyRoot,
szSubkey,
0L,
NULL,
REG_OPTION_NON_VOLATILE,
samMask,
NULL,
hKey,
&dw ) ;
The above fails to create the key.

We have tried four versions of our TSMS spanning many changes but the install acts the same.
This does not happen on any other Windows OS we test on but we do not test on Windows 2003 Storage Server R2 being that it is an OEM product. We did test on Windows server 2003 R2 x64 and do not see this problem.

Do you have any suggestions on how to tackle this problem?
I have full installation traces but can only see that the registry work is being refused. I can't see why.

View 1 Replies View Related

Newbie Here With A Newbie Error - Getting Database ... Already Exists.

Feb 24, 2007

Hi there
I sorry if I have placed this query in the wrong place.
I'm getting to grips with ASP.net 2, slowly but surely! 
When i try to access my site which uses a Sql Server 2005 express DB i am receiving the following error:

Server Error in '/jarebu/site1' Application.


Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.Source Error:



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



[SqlException (0x80131904): Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.
Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735075
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
 
 This is the connection string that I am using:
 <connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;Initial Catalog=ASPNETDB;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
 
The database is definitly in the folder that the error message relates to.
What I'm finding confusing is that the connection string seems to be finding "aranga"s database.
Is it something daft?
 
Many thanks.
James 

View 1 Replies View Related

Convert Composite Primary Key Into Simple Primary Key

Jan 11, 2007

Uma writes "Hi Dear,
I have A Table , Which Primary key consists of 6 columns.
total Number of Columns in the table are 16. Now i Want to Convert my Composite Primary key into simple primary key.there are already 2200 records in the table and no referential integrity (foriegn key ) exist.

may i convert Composite Primary key into simple primary key in thr table like this.



Thanks,
Uma"

View 1 Replies View Related

Adding Primary Key To A Table Which Has Already A Primary Key

Aug 28, 2002

Hi all,
Can anyone suggest me on Adding primary key to a table which has already a primary key.

Thanks,
Jeyam

View 9 Replies View Related

Document Storage

Dec 23, 2003

Hello Everyone and thanks for your help in advance. I am developing a document storage application for an intranet that will store various Word, Excel, and PDF documents. Most of the examples I see utilize SQL Server and an image field rather than the FileSystem Object to store documents. My concern with this method is that some of the documents may be several hundred pages (not exactly sure of the actual file size yet, but they must be fairly large). My question is, where does the use of SQL Server become impractical for this type of application? Any insight would be greatly appreciated. Thanks.

View 1 Replies View Related

Max Table Storage

Feb 20, 2002

Hello,

Does anyone know the upper limit of data size that one SQL 2K table can hold. I've seen 50GB tables in some warehousing servers, but what is the true limit. Soes the limit vary with the SQL2k version?

Thanks!

View 1 Replies View Related

Can You Specify A Drive For Storage?

Jun 7, 2004

I have an MSDE installation on Windows server 2003. It looks like the C: drive is taking the brunt of the data when I load up the database. I would like to specify a different drive for data...Is there a way to do this?

View 1 Replies View Related

Sql Table Storage

Feb 21, 2005

How should i know size of the table in the DB. suppose my DB has 5 tables and the size of the DB is 500 MB. How can I know size of the indivdual table.

Thanks.

View 6 Replies View Related

SQL Storage Images

Feb 28, 2006

greetings!!!

Help me please!

I'm migrating a images DB of a system
I know the structure of the data tables and all type of data in it
How can I learn about the STORAGE of IMAGES? In sql Server
Where can I found information about that?
I need to know something about that topic
usually, whats the way for image’s storage ?

View 5 Replies View Related

Storage Strategy

May 30, 2006

Hi guys.

I am currently developing a system thats stores exchange stats in a db. Since our customers are companies with 20 employees up to 5 000 there a a big difference in the volume of data needed to be stored.

We currently thinking of supplying a SQL Server Express DB to the small customers and suggest a SQL Server to the bigger.

But since I would like to use the same structure for both types of customers I wonder how should i design the storeage.

Since the could be from 500 records a day up to 20 000. There are quite simple recordes with only simple datatypes. about 15 fields with no more than 10 chars each, mostly 2.

Should i separate the data in diffrent tables for a week or a day etc.
Since I am only going to filter data on 1 or 2 fields the data will be easly indexed.

The reports generated will almost always only use 1-3 months of data, but historical reports have to be possible.

My question are ofcourse:
Whats the best solution for me?

Thanks in advance:)

/Johan Wendelstam
Sweden

View 10 Replies View Related

Storage - Transaction Log...

Jun 2, 2006

In MSQL Server 2000 how can I expand or use multiple transaction logs because the hard disk i am using windows dont have more than 4 GB free and the query i want to run overcomes this space.
I have another one HDD with 20-30 GB free space and i want to use this disk so to use a second transaction log or move this log to this disk.
Can this be happen and how ????

Thank you in advance

View 1 Replies View Related

Storage Information

Feb 23, 2007

additional to data, what other type of information can be store in sql databases, i need to store pictures and mp3's that can be done, if not do you know what storage can be used for this purpose?

View 2 Replies View Related

Image Storage

Jun 19, 2007

I have recently designed and built my first database using SQL server 2005 express. I have included an image (BLOB) column in one of the database tables. This is a bad idea according to some experts, and some say it is OK!

I am currently carrying out a trial with just 3 pictures via Visual Basic 2005 express forms, and there is no problem so far as the images are displayed for each record. But I anticipate between 300 - 1000 images for the table, and this could pose real problems for SQL server 2005 express and Visual Basic 2005 express, I guess.

I have just been reading that the cost of storing large images in the database is too high! I have also read it's better to store images (BLOB) into the file system because it is cheaper to store them no matter how many there are.

But the question is how I can reference an image in this path: C:PictureProductGrocery0052745.jpg in the database table, so that when I select a record Visual Basic 2005 forms the image is displayed accordingly, similar as when stored directly in the database table? Your help very much appreciated.

View 2 Replies View Related

Varchar(max) And Off-row Storage

Jun 20, 2007

From what I've read, if a row contains more than 8060 bytes and has varchar(MAX) columns in it, the data in those varchar(MAX) columns will be stored off-row. But what happens if you have two varchar(8000) columns instead and both contain more than 4030 bytes, is the data for both stored off-row? If so, just for that row, or for all rows in that table? And is there ever a good reason to have two varchar(8000) columns in a SQL Server 2005 table, instead of using varchar(MAX)?

View 6 Replies View Related

'Storage' Missing

Nov 13, 2007

Hey,

i don't see in my sql server 2005 the 'storage' under
Databases/MyDatabase/STORAGE for the full text catalogs.

How can I activate it? On an other computer I'm running the same version of my sql server 2005 i can see the storage label to click on...

I've searched so long without any mathces. Hope you can help me!!!

Thanks,
Steven

View 3 Replies View Related

Maximun Storage

Mar 25, 2008

Hi All
from following link
http://msdn2.microsoft.com/en-us/library/ms143432.aspx
i got this information

Bytes per row
8,060
Bytes per varchar(max), varbinary(max), xml, text, or image column
2^31-1
Characters per ntext or nvarchar(max) column
2^30-1

so is it means we can store in nvarchar(max) or varchar(max) upto 2^31-1 characters/bytes. but on the other hand we can store only 8060 bytes in a row. so the concept of Row-Overflow Data Exceeding 8 KB comes into picture.
my questions is suppose i declare a variable of type varchar(max) then i can store upto 2^30-1 bytes in it and SQL Server on its own determine how and where to stores it.

View 4 Replies View Related

Storage Snapshot

Jul 20, 2005

hello group,is it possible to do a storage snapshot of a running ms-sql databasewithout losing transactions?What tasks must be done before such a snapshot.thanks in advance,Bernhard

View 7 Replies View Related

How Many Data Can Storage Into Sql Ce

Mar 16, 2007

Hi,

i want to know how many data can storage into sql server compact edition. I've got a db into a pocket pc that has a table with about 2000 records inside; are they too records?

View 5 Replies View Related

Checksum Storage

Feb 18, 2008

it sounds like a column can be added to each row in a table that is the checksum or binary_checksum of an expression. How many bytes do each of these occupy? Does the answer depend on the number and/or length of items in the expression?

View 4 Replies View Related

Storage Error

Feb 15, 2007

i am using compact framework do create applications now i am facing a problem....

i am getting a "Not enough storage is available to complete this operation" exception

i am testing my application on O2 pocket pc. running Sql mobile edition.......... and this error is causing me trouble this is espically happening when i am opening sql server connection or calling complex joined queries..... or so... any ideas???

View 1 Replies View Related

Volatile Storage

Feb 16, 2007

I am new to windows mobile development, and I am looking to create an application (C#) which uses the SQL server CE. I am curious what to do about data loss. I have a Windows Mobile 2003 PDA, which means half of my storage is main memory (volatile) and the other is built in storage (no volatile).

I expect I would want to install my application to the main memory, along with the database. I Planned to give the user the abililty to select a subset of properties for running the application and storing them in the DB for running. But if the user's battery runs out I wouldn't want them to loose all of the information in the database (ie configurable property selections chosen by the user).

If the user looses the application, I plan to have them reinstall it (which would recreate the database). But I would like them to be able to load a 'configuration' file from their Built in storage area when the app is reinstalled, so that they don't loose all of their settings.

Expererience with this? or reccomendations on how to go about it?

View 3 Replies View Related

Auto Incremented Integer Primary Keys Vs Varchar Primary Keys

Aug 13, 2007

Hi,

I have recently been looking at a database and wondered if anyone can tell me what the advantages are supporting a unique collumn, which can essentially be seen as the primary key, with an identity seed integer primary key.

For example:

id [unique integer auto incremented primary key - not null],
ClientCode [unique index varchar - not null],
name [varchar null],
surname [varchar null]

isn't it just better to use ClientCode as the primary key straight of because when one references the above table, it can be done easier with the ClientCode since you dont have to do a lookup on the ClientCode everytime.

Regards
Mike

View 7 Replies View Related

Un Limited Data Storage

Aug 29, 2005

hi all,
I have a field which name is Information
and it type is Varchar (8000),but some time data access than 8000 character, my client told me,make this field to store Unlimited data.
So how can i achive this task, i m using VS 2003 (ASP.NET with VB.NET) with SQL 2000.
Thanks
Shally

View 2 Replies View Related

Storage Area Networks?

Sep 6, 2001

Does anyone know if SQL7 will work with Storage Area Networks(SAN's)? I've read that SQL2000 implements something called a Virtual Interface System Area Network (VI SAN) that allows communication with devices connected via a SAN.

My site is installing a SAN and I need to know if SQL7 can utilize those resources (Storage,etc) and how reliable if so.
Randy

View 1 Replies View Related

Not Enough Storage Is Available To Complete This Operation

Aug 31, 2004

Hi,

I am having trouble trying to import a big file (aprox 250Mb is size) into an SQL Server database and I keep getting the message:

"Not enough storage is available to complete this operation".

The application tries to import the file by executing a stored procedure:

CREATE PROCEDURE sp_updateMaterialBlob
@MaterialId Int,
@BLOB image
AS
BEGIN
Update Material SET blob = @blob where id = @materialId
END

The application uses an ADO connection. I've tried increasing the memory of the client machine but that didn't work. Whenever I do run the import, nearly all the memory on the machine is used up but every time after several hours I get the same error message. What is the cause of the problem and how do I resolve it? Ideally I want to use my application to do the import rather than anything bespoke.

View 7 Replies View Related

Bit Datatypes Physical Storage

Feb 15, 2005

Can anyone explain to me how a column defined with a "bit null" datatype is physically stored in MSSQL? Is it stored like a "tinyint null" physically? In other words, how many bytes on the row on the page does a "bit null" datatype consume (assuming a non-null value 0, or 1 is the current value).


Is there any good documentation about the physical storage layout for a data page?

Thanks -

View 13 Replies View Related

SQL + File Storage + Delphi

May 19, 2008

I am using Delphi 7 and need to save mulitple documents that range from 2K KB to 200K KB. These need to be stored in the database for inclusion in the database backup.

When i am working on the 200K KB file i continusely run out of memory, how can i resolve this.

View 1 Replies View Related

SQL 2012 :: Server On NAS Storage

Oct 28, 2014

I'm in the situation where we are suffering of poor performance on our SAN storage (VPlex) but it is mainly due to the quantity of data of different types which are on it (other applications, other I/O profile, bad storage usage...). As we plan to dedicate an ESX for SQL Server, we decide to have a new storage type. So we will go with NETAPP Clustered Data ONTAP on NAS technology.

Storage team want to enable only NFS protocol, so I'm wondering how SQL Server will handle that ? I read that NFS wasn't optimize for SQL Server and that block level (SAN) should be preferred.

View 7 Replies View Related

Anyone Out There Using Vardecimal Storage Format?

Jun 21, 2007

Just curious to know what you think.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved