Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how ro create a table with multiple coloumns defined to a single primary key


how ro create a table with multiple coloumns defined to a single primary key

Author
Message
prassu.ibm
prassu.ibm
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 57
how ro create a table with multiple coloumns defined to a single primary key, please provide examples of any such table
LutzM
LutzM
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 7001 Visits: 13559
I'm sure this link will help you.



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
bright_day
bright_day
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 47
It is very important for you to know how to read tsql documentation. Even better, download it and install locally. Effort on that will give you many benefits and faster advancement in knowledge.
Here is example of multicolumn primary key, along with two foreign keys:

CREATE TABLE MyTable
(
ForeignId1 int,
ForeignId2 int,
CONSTRAINT MyTable_PK
PRIMARY KEY ( ForeignID1, ForeignID2 ),
CONSTRAINT MyTable_FK_Table1
FOREIGN KEY ( ForeignID1 ) REFERENCES Table1( ID ),
CONSTRAINT MyTable_FK_Table2
FOREIGN KEY ( ForeignID2 ) REFERENCES Table2( ID )
)



Primary key = not null constraint + unique index

Is is recommended to give table a PK that is artificial, e.g. "int identity".
Vedran Kesegic
Vedran Kesegic
Old Hand
Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)

Group: General Forum Members
Points: 382 Visits: 1255
Try a free tool XDetails (www.sqlxdetails.com). It really simple presents multicolumn PK, FK, column comments and other features.

_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths

prassu.ibm
prassu.ibm
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 57
@bright_day

can you please provide me any link where i can learn tsql documentation as suggested by you, i am learning t-Sql development, kindly need assistance of experienced.
Vedran Kesegic
Vedran Kesegic
Old Hand
Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)Old Hand (382 reputation)

Group: General Forum Members
Points: 382 Visits: 1255
First, download the documentation. It is called "books online". Search with google books online for your version of sql server. This is example for SQL 2008R2 (put that in google):

sql 2008R2 books online download

First result is at Microsoft site. Download and install.
When you are in query editor of SQL Server Management Studio, you can press F1 when text cursor is the keyword or function you want the details on. CONVERT function is the one that I use F1 the most, so I have marked that page as "Favorite" to be easily accessible.

How to read T-SQL command syntax specification:
http://msdn.microsoft.com/en-us/library/ms177563.aspx

In short:
[abc] = means that "abc" (anything within brackets) is optional, you can omit it
{a | b | c } = means that contents of curly brackets is NOT optional. You HAVE TO select exactly one of the values that are separated by "|". E.g: a or b or c.
[{a | b}] = that means you have to select a or b or nothing. It is the same as [ a | b ]
{a | b}[,...n] = "[,...n]" means you can repeat that thing before as many as you like, as long as you separate them with comma. E.g: a,b,a,a,b,b,b,b
<something> = contents of "something" is described somewhere else, usually in the same page just below.

Try to explain this:
CREATE TABLE 
[ database_name.[ owner ] . | owner. ] table_name
( { < column_definition >
| column_name AS computed_column_expression
| < table_constraint > } [ ,...n ]
)



Try to find function reference and read about all the functions that are built-in in sql server and try to use each in example. That's a good start.

Good luck!

_____________________________________________________
Microsoft Certified Master: SQL Server 2008
XDetails Addin - for SQL Developers
blog.sqlxdetails.com - Transaction log myths

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search