By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,806 Members | 1,837 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,806 IT Pros & Developers. It's quick & easy.

TSQL query

P: 1
I had to write a valid TSQL query that does all the following in a transaction and will rollback if any system error is thrown.

Create the following tables Customer, Order and Address where Customer can have many Orders and many Addresses. Order can only have one Address. Customer will have a column called CustomerNum of type NVARCHAR(3).
Develop a SQL function that provides a unique, incremented CustomerNum in the form 001, 002, 010 etc. Using that function, insert 10 new Customer rows. Note: the function needs to be as efficient as possible. Add any indexes that might be needed.
Insert 1 Address per Customer.
Insert 2 Orders per Customer.
Ensure each Order has a valid Address from the corresponding Customer.
Ensure that if the tables already exist that they are dropped from the database.
Ensure all tables use primary keys and are of type GUID.

Any quick response is really appreciated.
Nov 16 '09 #1
Share this Question
Share on Google+
1 Reply


debasisdas
Expert 5K+
P: 8,127
Do your homework /assignment yourself.
Nov 16 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.