Showing posts with label production. Show all posts
Showing posts with label production. Show all posts

Friday, March 9, 2012

I need to make a minor change to a SQL Server script that is in production. Need advice so

Hello. I am not very strong with SQL server. But I know enough to get my way around. The reason I am asking for
help is that I need to change a SQL server script that resides on one of the production database servers of the
company I work for. I just need to add two new lines to the stored procedure.(See the lines that are bolded.) These
values are [MO_FAX],[MO_EMAIL].

Can someone tell me if there is a best way of going about doing this? Can I just simply open up SQL server and
quickly make the change? The big issue here is that this script is used in production. So I am just a little worried
about screwing something up. Anyway, I would appreciate some good advice on this?

/* Returns all data given the region and country */
ALTER PROCEDURE [dbo].[GetAllInfomration]

AS
SELECT
[COUNTRY],
[Company_NAME],
[CompanyAddress],
[CompanyPhone],

[MO_FAX]
[MO_EMAIL]

[CompanyFax],

FROM [InfoLookup].[dbo].[Company_Contact]

RETURN

Assuming the columns are in the same table, you need a comma after the column names.

/* Returns all data given the region and country */
ALTER PROCEDURE [dbo].[GetAllInfomration]

AS
SELECT
[COUNTRY],
[Company_NAME],
[CompanyAddress],
[CompanyPhone],

[MO_FAX],
[MO_EMAIL],

[CompanyFax],

FROM [InfoLookup].[dbo].[Company_Contact]

RETURN

|||

Fix comma, and I would also recommend to move you new columns to the end of the result set so if any of your production application use columns ID number instead of name it will not blow up.

SELECT
[COUNTRY],
[Company_NAME],
[CompanyAddress],
[CompanyPhone],
[CompanyFax],
[MO_FAX],
[MO_EMAIL]

FROM [InfoLookup].[dbo].[Company_Contact]

|||

Cool. Thank you for the advice, I will take it.

Just curious. Typically does it matter what order the columns are in? Specifically do they ever have to map exactly to the order of the columns defined in the data table?

For example if my table columns are in the following order

(PK) FirstName Varchar(40)

(FK) LastName Varchar(40)

Social Security Varchar(8)

Would a corresponding sql script need to be in the same order. i.e.

[]FirstName]

[Last Name]

Social Security.

Or can it for example be in the reverse order of the way it is defined in the table.

Social Security

[Last Name]

[Last Name]

|||No the order doesnt matter as long as your application is not referring to the columns by their position. I've seen some .NET code with datareader where the code accesses columns by their positions. Perhaps there are other scenarios other .NETters can explain..|||

Yes most programmers reference column by column order number when they try to get value from column because it is faster when by column name.

But as long as they use column names referencing to data it will work, but if you have no idea how you result is processed by other users just do not change columns order.

Sometimes is also possible that they have fixed schema for result from you SP and you new columns will generate errors if they will run your SP.

You also should not change column name format (small capital letters) because for example XML is very sensitive on it and it will not recognize columns correctly if they have different so Field is different then field for XML

Thanks

Sunday, February 19, 2012

i need help

XYZ Company is a Car production company. It has four factories and many distribution outlets spread across the country. The company keeps online records of the sales of its cars. It also creates batched Production schedules on the basis of the sales of the car. The car production is done at a nearest factory so that the cost of transfer of cars to distribution centre is minimized. Each factory also maintains its inventory. The company maintains a distributed database management system keeping all the above information. The following information may be stored in the Distribution and Inventory Management System of the Company:

(Please note that the following description may lead to un-normalized relations, normalize them wherever required. You may also add more tables as per your analysis.)

Data store NameDescription
Distribution OutletsIt includes outlet code, outlet name, outlet address, list of car models, sales made for each model etc.
Factory It may be keeping information about each car inventory items (Model wise). It includes item code, item name, model in which this item is used, quantity used in a single Car unit, and quantity in stock, time taken to produce a batch of 100 cars, etc. This information is stored factory wise. Each factory will have separate minimum stock and reorder level based on its capacity.
Batched OrderIt includes details on overall sales of Cars at various outlets, all such sales are put together to generate a consolidated orders for factories. On the basis of such orders the factories make Cars.

Assume that only following two applications exists:

(a)Keeping track of status of Inventory so that the delays in production of Cars can be minimised. Proper reorder levels should be kept so that a given order of cars is completed with full assembly load in desired time.

(b)It evaluates the performance of each distribution outlet of the Company.
Design a distributed database assuming that at present the company has only 10 outlets. Also assume statistics, which justifies your design.

Your design should include:

(i)The global schema, fragmentation schema and allocation schema.
(ii)SQL commands/ application code for above queries/applications.
(iii)How the response for application 1 and 2 will be generated? Assuming these are global queries, explain how various fragments will be combined to generate the query response.
(iv)Implement the database at least using a centralized database management system (make suitable adjustments in your design).It looks like it is your school assignment.
Show us some work and where you have a problem.|||Kindly post what you have tried so far .