|
Hi,
I want to know what are the naming conventions for creating the above mentioned? I went through some of the adventure works tables and looking at the indexes they either start with IX or AK, for example:
IX_EmployeeDepartmentHistory_DepartmentID
Please advise.
Brendan
|
|
|
|
|
Hi,
I have 3 tables, namely:
CategoryGroup
CategoriesInCategoryGroup
Categorty
CategoriesInCategoryGroup has only 2 fields, which I made the primary key each, namely CategoryGroupId and CategortyId, and they each reference the corresponding table. So basically they are foreign keys.
I have a question when creating an index in the CategoriesInCategoryGroup table. Do I create 1 index, or should I create a separate index for CategoryGroupId and CategortyId in the CategoriesInCategoryGroup table?
Please advise.
Brendan
|
|
|
|
|
Is always a good idea to create an index for each field (or group of fields) that forms a FK
Only in few cases you could not create such an index, i.e. when it is the first field in an already existing index or is equal to de PK.
Habetis bona deum
|
|
|
|
|
Hi Brendan
I would expect CategoriesInCategoryGroup to have CategoryGroupId and CategortyId as a clustered primary key. You would then normally create a separate non-clustered index on the CategoryId column.
If you are not using SQL-Server then the second index should be combine CategortyId and CategoryGroupId.
Regards
Andy
|
|
|
|
|
OK, I realise this is generally a SQL server-oriented forum, but I'm a bit stumped so I'll post anyway.
I was debugging an Oracle package which does a massive number of updates (9,6000,000 approx.) and it hung. I tried to kill the process but that didn't work either, and I had to kill TOAD eventually. When I went back in, I found that Oracle had placed a lock on the package, so I can't compile, change, or even drop the object. Does anyone know where I need to go in Oracle to release this lock? I don't have a DBA on-site here, I'm pretty much on my own.
Smokie, this is not 'Nam. This is bowling. There are rules.
|
|
|
|
|
Hi,
if we are trying to add the several columns in select statement without using Aggregate functions and only one condition in group by.
how can we do that ??
|
|
|
|
|
I'm not sure I understand you. Can you throw some SQL my way...
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
praveenanand wrote: if we are trying to add the several columns in select statement without using Aggregate functions and only one condition in group by.
You can't. Each column not specified in the GROUP BY clause must be part of an aggregate on the SELECT. If you think about what it is doing you will see why.
|
|
|
|
|
Hello,
I'm working on a project and its deadline is comming really close. I have a State and cities Table to store the names of the states and cities of the US. I've populated the State Table manually but the cities is like quite a hectic task. Is there some way that I can load the names of teh cities programaticaly (thru a file or something) in to the db
I'm using SQL 2005 and .NET 2.0
Any suggestions, guidlines are welcome
Thanks in advance
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
When I needed to load a list of all the countries in the world I used an XMLDataSource and found an XML file with all the countries in it. I think I found the file at the US Census Bureau web site if I'm not mistaken.
I'm sure you could find an XML list with all the cities and then you could load it and save it to the db.
And how do you manage to submit a post on the 13th of December? Pretty crazy.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
ok that's gr8 I'll chk it out to see what I can find on google.
Rohde wrote: And how do you manage to submit a post on the 13th of December? Pretty crazy.
That one was over the top Sir!! Didnt get it????
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
Rocky# wrote: That one was over the top Sir!! Didnt get it????
Heh
When I reply to your post the beloved CP displays:
Reply to Message header: Forum: SQL / ADO / ADO.NET
Subject: Re: Is there a way to efficiently load the cities of US into the database
Sender: Rocky#
Date: Thursday, December 13, 2007 2:24:00 AM
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
oh wow! that mean ATTN CP web masters!! There's a little issue around here. I wonder where did that come from
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
I have a problem in selecting one row of a table
1. Could you help me to select only one row without querying by the data inside the table, please ?
2. How i can identify the row ?
thanks and regards,
azumike
|
|
|
|
|
You use a primary key.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
thanks for your inquiry,I have it, but, i want to select row without key on the table,
i mean that i want to select 1st row, 2nd row etc.
example i have table:
table name is: "person"
No | property
----------------------
1 | house
1 | name
1 | age
i want to select 2nd row but i don't wanna use :
select * from person
where property='name'
any other way ?
regards,
azumike
|
|
|
|
|
You cannot select a row from a database table without a unique identifier, i.e. a key. How else should the database know what to give you?
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
|
help anyone!! phaleezz!!
i just want to combine the returned values(both varchar types)of my two 'user defined function' as one field in my sql statement
my codes like this..
<br />
select cast (UDF_getCellNos + '/' + UDF_GetLandLines as varchar(100)) as Contact_Info from tblCrewInfo<br />
if both my UDF's returns a value..
my column 'Contact_Info' returns '09179673815 / (02)9614337'
works out fine..
but if either of my UDF's does not return a value...
my column 'Contact_Info' returns 'null'
it's supposed to return the value of the other UDF..
and thats my problem
..is there any other way i can get my UDF's returned values as one column, even if one doesn't have a return value?
any help will be appreciated...
thanks in advance
|
|
|
|
|
Concatenating a NULL value with a string will always return NULL. Use the ISNULL function to convert NULL values to empty strings to prevent this happening.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
woahhh you're a god man thanks for a fast reply
thanks pmarfleet
damn i really love this site!!
|
|
|
|
|
anthoy wrote: damn i really love this site!!
Yep, CodeProject rocks
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I want to connect to sql server on other VLAN (C# 2005 ).
Exam:
Client IP : 192.168.10.100
SQL server IP : 192.168.20.200
Is it possible???
QuynhTD
|
|
|
|
|
Hi everybody,
I wrote an app that processes a list of invoices and for each one fires a stored procedure against a SQL2000 DB. The workload is usually of about 4 to 6 thousand items. All the store procedure does is insert a record in the transactions table and updates the customer's balance in a second table.
It appears to work great, but suddenly the SP's performance drops down, for a number of records it works at closely to 200 items/sec and then 1 or 2 items/sec. This performace decay lasts for about 10 secs and then regains it original performance. Monitoring the CPU usage I noticed that it is somewhere around 60-70% and then drops to 2%.
I already tried eliminating the pre-instaled DEMO Alerts and I have no tasks scheduled in the SQLAgent.
I also ran a trace using the Profiler and the delay does never occure in the same part the SP. The truth is that I do not know what to look for or where to look for. Can anybody offer guidance? Thanks a lot. OH! and HAPPY HOLIDAYS!!!
I wish I could post answers rather than questions
|
|
|
|
|
alexvw wrote: for a number of records it works at closely to 200 items/sec and then 1 or 2 items/sec
alexvw wrote: Monitoring the CPU usage I noticed that it is somewhere around 60-70% and then drops to 2%.
Looking at the above, I can only guess that SQL Server is flushing dirty pages to disk.
Whatever modifications there are, it's done in memory(RAM). And when SQL Server runs out of allocated RAM, it has to flush all the dirty pages in memory to disk, and free up the RAM for more records. Most likely that's what is happening.
Check your I/O rate when the SP slows down, you'll more likely see an increase in I/O. And there's not much work for the processor at this time(and hence the drop in CPU)
The SP runs fast for sometime because all records are in memory. Then the dirty pages need to flushed and new pages need to be loaded. This usually happens in different non-overlapping threads. But the fact that all these threads have to wait for the same resource(Disk Drive), slows them down at some point.
Try allocating more memory to SQL Server(usually means "add more RAM"). But I believe that this problem will be solved to an extent when you move to production servers with multiple processors and drives.
Good Luck!
|
|
|
|