Sql Server Keys Out Of Order On Page

Feb 14, 2006

I am getting the following error in the database..

B-tree chain linkage mismatch
Keys out of order on page


I have run the DBCC Repair_rebuild with data_loss.
But this has not helped to resolve the issue. It is finding errors in the Primary Key Linkage.

Please assist.
Thanks for your help.
Karthik

View 20 Replies


ADVERTISEMENT

SQL 2012 :: Get Order In Which Foreign Keys Are Applied

Sep 10, 2015

Probably not the best "Subject Title", but no the less what I am looking for is a way to get the order in which I should insert data into a table that has 10 FK's to it. I have queries that list them out for me, but they do that in what seems to be alphabetical order. You can also right click the table in question and select view dependencies, but that as well appears to be in alphabetical order.

Is there any query or any way to see what order I should be inserting and/or deleting data into FK tables?

View 0 Replies View Related

Page 2 - Order By

Sep 6, 2007

lol, you still still didn't answer the most important questions about what you want the results to be, and whether the data is consistent.

View 1 Replies View Related

Page 2 - SQL ORDER BY Problem

Jan 24, 2005

yeah, you're right, it isn't totally clear: Quote: MS SQL Development forum discussing administration, MS SQL queries, and other MS SQL-related topics. i suppose "MS SQL" could be interpreted as "any product from microsoft that uses the sql language" but unfortunately what it really means is "microsoft sql server"

anyhow...

please show your latest query that doesn't work

View 8 Replies View Related

Order By Is Slowing Page Load

Mar 14, 2007

hi guys,
the following test script works fine and displays a list of cars from the fairly small database, but if I specify the sort order in the querystring, the page takes ages to display and usually times out. Can someone look over it please and tell me where I can fine-tune it for performance or redundant code?
thanks
M


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim oRS,oConn,myOrder,strSQL

Set oRS = Server.CreateObject("ADODB.Recordset")
Set oConn = Server.CreateObject("ADODB.Connection")
'next, a couple of test lines to prevent timeout (seems to have no effect)
oConn.CommandTimeout = 0
Server.ScriptTimeout = 0

Set strOrder = Request.QueryString("Order")

oConn.ConnectionString = "Provider=MSDASQL;DRIVER=SQL Server;SERVER=address;UID=userID;PWD=password;DATA BASE=name"
oConn.Open
%>

</head>

<body>
<%
strSQL = "Select make,model,price from vehicles where cat = 'car' AND active = 'yes'"
if strOrder <> "" then
strSQL = strSQL & " ORDER BY " & strOrder
end if

oRS.Open strSQL, oConn, 2, 3

oRS.moveFirst
Do while not oRS.eof

make = oRS("make")
model = oRS("model")
price = oRS("price")


%>
<%=make%> <%=model%> <%=price%><BR>
<%
oRS.MoveNext
loop

oRS.close
set oRS= nothing
oConn.close
set oConn=nothing
%>
</body>
</html>

View 14 Replies View Related

Select Records From Two Tables, Plus Page And Order Them?

Feb 7, 2008

Hi,

I'm trying to look for an efficient way to select records from two tables, combine them (not just one set above the other) and also efficiently page the results as well as dynamically order by specific columns. So far I have this....

DECLARE @Temp TABLE
(
IDINTNOT NULL,
NameNVARCHAR(128)NOT NULL,
TypeCHAR(1)NOT NULL
)

INSERT INTO @Temp
SELECT i.ID, i.Name, Type = 'I' FROM Item i
UNION
SELECT p.ID, p.Name, Type = 'P'FROM Package p

SELECT * FROM @Temp
ORDER BY Name ASC

I was going to then implement some sort of of ROW_NUMBER like paging and ordering on the @Temp table variable. Problem is there could be potentially 1000's or more Items and Packages and they would all go in this single Temp table before having records 1 to 10 returned. Is there a more efficient way of doing this before I proceed any further?

Many thanks for any help! :)

View 10 Replies View Related

Creating Inter-table Relationships Using Primary Keys/Foreign Keys Problem

Apr 11, 2006

Hello again,

I'm going through my tables and rewriting them so that I can create relationship-based constraints and create foreign keys among my tables. I didn't have a problem with a few of the tables but I seem to have come across a slightly confusing hiccup.

Here's the query for my Classes table:

Code:

CREATE TABLE Classes
(
class_id
INT
IDENTITY
PRIMARY KEY
NOT NULL,

teacher_id
INT
NOT NULL,

class_title
VARCHAR(50)
NOT NULL,

class_grade
SMALLINT
NOT NULL
DEFAULT 6,

class_tardies
SMALLINT
NOT NULL
DEFAULT 0,

class_absences
SMALLINT
NOT NULL
DEFAULT 0,

CONSTRAINT Teacher_instructs_ClassFKIndex1 FOREIGN KEY (teacher_id)
REFERENCES Users (user_id)
)

This statement runs without problems and I Create the relationship with my Users table just fine, having renamed it to teacher_id. I have a 1:n relationship between users and tables AND an n:m relationship because a user can be a student or a teacher, the difference is one field, user_type, which denotes what type of user a person is. In any case, the relationship that's 1:n from users to classes is that of the teacher instructing the class. The problem exists when I run my query for the intermediary table between the class and the gradebook:

Code:

CREATE TABLE Classes_have_Grades
(
class_id
INT
PRIMARY KEY
NOT NULL,

teacher_id
INT
NOT NULL,

grade_id
INT
NOT NULL,

CONSTRAINT Grades_for_ClassesFKIndex1 FOREIGN KEY (grade_id)
REFERENCES Grades (grade_id),

CONSTRAINT Classes_have_gradesFKIndex2 FOREIGN KEY (class_id, teacher_id)
REFERENCES Classes (class_id, teacher_id)
)

Query Analyzer spits out: Quote: Originally Posted by Query Analyzer There are no primary or candidate keys in the referenced table 'Classes' that match the referencing column list in the foreign key 'Classes_have_gradesFKIndex2'. Now, I know in SQL Server 2000 you can only have one primary key. Does that mean I can have a multi-columned Primary key (which is in fact what I would like) or does that mean that just one field can be a primary key and that a table can have only the one primary key?

In addition, what is a "candidate" key? Will making the other fields "Candidate" keys solve my problem?

Thank you for your assistance.

View 1 Replies View Related

Creating Indexes On Columns That Are Foreign Keys To Primary Keys Of Other Tables

Jul 16, 2014

what the best practice is for creating indexes on columns that are foreign keys to the primary keys of other tables. For example:

[Schools] [Students]
---------------- -----------------
| SchoolId PK|<-. | StudentId PK|
| SchoolName | '--| SchoolId |
---------------- | StudentName |
-----------------

The foreign key above is as:

ALTER TABLE [Students] WITH CHECK ADD CONSTRAINT [FK_Students_Schools]
FOREIGN KEY([SchoolId]) REFERENCES [Schools] ([SchoolId])

What kind of index would ensure best performance for INSERTs/UPDATEs, so that SQL Server can most efficiently check the FK constraints? Would it be simply:

CREATE INDEX IX_Students_SchlId ON Students (SchoolId)
Or
CREATE INDEX IX_Students_SchlId ON Students (SchoolId, StudentId)

In other words, what's best practice for adding an index which best supports a Foreign Key constraint?

View 4 Replies View Related

How To Access A .asp Page Or .aspx Page From A Store Procedure In Sql Server 2000

Sep 21, 2006

Hi, I wanted to know that can we access a webpagefrom a store procedure in sql server 2000 like we run a exe file from sql server. Bye.

View 1 Replies View Related

SQL Server 2012 :: Force Page Footer At Bottom Of The Page

Mar 12, 2015

I have a report with tablix. when tablix returns no rows Footer is coming all the way up . How to display the footer at the bottom of the page all time.

View 0 Replies View Related

Generate Script For Primary Keys And Foreing Keys

May 16, 2008



Pls let me know How I generate script for All primary keys and foreign keys in a table. Thereafter that can be used to add primary keys and foreign keys in another databse with same structure.

Also how I script default and other constraints of a table?

View 2 Replies View Related

Urgent !!!!! Nee Explanation On Primary Keys And FK Keys

Jul 15, 2002

Can somebody explain to me how to best do inserts where you have primary keys and foreign keys.l'm battling.

Is there an article on primary keys/Pk ?

View 1 Replies View Related

Foreign Keys - On Which Kind Of Keys Do The Base On?

Nov 22, 2007

Hello!I have a table A with fields id,startdate and other fields. id and startdateare in the primary key.In the table B I want to introduce a Foreign key to field id of table A.Is this possible? If yes, which kind of key I have to build in table A?Thx in advance,Fritz

View 6 Replies View Related

Reporting Services :: All Record Are Displaying On One Page - How To Display Page By Page

Nov 11, 2015

I have created one reports but all the records are displaying on one page.find a solution to display the records page by page. I created the same report without group so the records are displaying in page by page.

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

I Need To Pass Data Entered /created On The First Page To The Next Page And Populate The Next Page With Some Data From The Fir

Nov 28, 2006

Hello I have a project that uses a large number of MS Data access pages created in Access 2003 and runs on MS SQL2005.

When I am on lets say my client, (first page in a series) data access page and I have completed the fields in the (DAP), I am directing my users to the next step of the registration process by means of a hyperlink to another Data access page in the same web but in a linked or sometimes different table.


I need to pass data entered /created on the first page to the next page and populate the next page with some data from the first page / table. (like staying on the client name and ID when i go to the next page)


I also need the first data access page to open and display a blank or new record. Not an existing record. I will also be looking to creata a drop down box as a record selector.


Any pointers in the right direction would be appreciated.
I am some what new to data access pages so a walk through would be nice but anything you got is welcome. Thanks Peter€Ś

View 2 Replies View Related

SQL Server - PRIMARY KEYS (autoincrement)...

Jan 12, 2005

In SQL Server 2000, I'm looking for input as to how to set up primary keys (PKs).

Is it safe to use the IDENTITY feature using AUTOINCREMENT as a setting for a PK, or is it best to generate my own and check for dups?

My concern is whether SQL Server at any point will taint the numbers used as the PK -- because as you know, these PKs are going to wind up linking into (relating into) other tables (e.g. client orders).

Certainly it's vital that the clientID not get lost/changed during any regular DB maintenance or use.

Any input would be appreciated.

View 1 Replies View Related

How Do You Generate Primary Keys With SQL Server?

Oct 26, 2005

Hi,

The way i generate my primary keys is to keep a table

PrimaryKeyTable
PrimaryKeyName : varchar (name of the primary key, for example UserID)
PrimaryKeyID : int (the next key should have the number stored in that
field, if it was 12 then next time i add a row the UserID will be 12)

After adding a row, i increment the value of primaryKeyID.

Is there a way to let SQL server to handle the primary key? To let SQL generate the key himself instead of me?

Thanks,

View 4 Replies View Related

Using SQL Server 2005 Public Keys In VB.Net

May 1, 2006

I'm creating an asymmetric key in SQL Server:

CREATE ASYMMETRIC KEY MY_KEY
WITH ALGORITHM = RSA_512
ENCRYPTION BY PASSWORD = 'password1@'

I'm then taking the public key...

SELECT public_key
FROM sys.asymmetric_keys
WHERE [name] = 'MY_KEY'

I'm trying to import this into VB.Net using RSACryptoServiceProvider.

Dim RSA As New
Security.Cryptography.RSACryptoServiceProvider(512)
RSA.ImportCspBlob(KeyBlobByteArray)

I have to add the following line to get it to not give me errors.
(Why?) But the data looks right when I look at the exponet and modulus
of the parameters that are exported and then immediately imported.
Something is obviously being thrown away when I do this, but I don't
know what. It's probably the key to the whole problem.

RSA.ImportParameters(RSA.ExportParameters(False))

I encrypt the message...

EncryptedMessageByteArray = RSA.Encrypt(MessageByteArray,
False)

And in SQL server I try to decrypt the message and I get NULL.

SET @DecryptedMessage =
DecryptByAsymKey (
AsymKey_ID('MY_KEY') ,
@EncryptedMessage ,
N'password1@')

I've noticed that the encrypted array is completely different in VB
than when I encrypt it in SQL (obviously), but I can't figure out how
to configure to the RSACryptoServiceProvider to match what SQL Server
is doing under the hood.

Any ideas?
Thanks,
Jerrill

View 10 Replies View Related

SQL Server, Master Detail Without Foreign Keys

Mar 27, 2007

As part of a project, I'm not allowed to use foreign keys, well can't.   But I have a problem with this master detail relationship (and a very simple one too).
Tables to begin with:
Invoice:
invoiceid : bigint indentity autoincrement primarykey
Detail:
invoiceid: bigint  -  detailnumber:bigint  -  desc : char20
Okay - I want to set these two tables up such than when I create a new invoice, and subsequently get the new invoiceid, and I start to add detail records to the detail table, I want the detailnumber to autoincrement when I do an SQL Insert.  Right now I have detailnumber as the primary key, so when you view the detail records, it looks like:
(invoiceid, detailnumber, desc) 1,1,text - 1,2,text - 1,3,text - 2,4, text on another invoice - 3,5, text
I want it to work like:
(invoiceid, detailnumber, desc) 1,1,text - 1,2,text - 1,3,text - 2,1, text on another invoice - 3,1, text
where the invoiceid and the detail number make up the primary key.
I seem to recall you could do this is PHP before it had foreign keys & such, and I'm completely drawing a blank on this.  BTW - I'm using enterprise manager to set this up, but I can use QA with a sample script to acheive the same.
I realize this may be (and probably is) off-topic here, but I can't figure out where to ask.
Thanks in advance.
 
 
 
 
 

View 3 Replies View Related

Foreign Keys In Server Management Studio

Jan 25, 2008

I think I did this before but how do you designate foreign keys in SQL Server Management Studio?

View 2 Replies View Related

SQL Server Express - Registry Keys On Vista

Apr 19, 2007

When I install SQL Express on my XP Machine, the registry keys under local machine (ie, MSSQL.1, etc) show up, but on my Vista 64bit machine, the MSSQL.1 etc keys are not there. SQL Server still works, but the reg keys are missing.

View 1 Replies View Related

Data Encyption Using Symmetric Keys Outside SQL Server

Jan 30, 2007

Hello. I have a problem that spans VB.net, SQL Server and SSIS but is rooted in the need to encrypt column data in SQL Server.

I would like to encrypt data that I am bringing into SQL Server in the Data transformation script component of an SSIS package. I have achieved this but I can't decrypt the data because the keys don't match. I would like to use symmetric key encryption but I don't see how to get the symmetric key that I created in SQL Server available to the VB.net script component in SSIS.

Please advise me if my approach is correct and what steps I need to take.

View 5 Replies View Related

Backing Up DPAPI Keys In Relation To SQL Server

Sep 13, 2007


Hi,
There alot of talk about Service Master and DB Master keys and the importance of backing them up seperately.
What about the DPAPI keys used to protect the Service Master keys. What procedures to I take to back those up during my database backup.
If I understand correctly, if I do a backup on one machine, and then try to restore in a different machine, I won't be able to decrypt data becuase the DPAPI keys don't "match".
This is assumming I don't use a password to protect my DB Master keys, I just rely on the service master to protect them.

Thanks for any help,

View 3 Replies View Related

Transact SQL :: Size Of Foreign Keys In Server 2012?

Jun 30, 2015

I have question about the size of foreign key’s in sql-server 2012. If I in one table had a foreign key of the “INT” type. Do it still cost 4 bytes of storage?

View 6 Replies View Related

SQL Server Admin 2014 :: Using Column Encryption With Symmetric Keys

Jun 25, 2015

I am trying to implement the column encryption on one of the tables, have used the below link as the reference and got stuck at the last step.

[URL] ....

I have completed the following steps so far.

- CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘myStrongPassword’

- CREATE CERTIFICATE MyCertificateName
WITH SUBJECT = 'A label for this certificate'

- CREATE SYMMETRIC KEY MySymmetricKeyName WITH
IDENTITY_VALUE = 'a fairly secure name',
ALGORITHM = AES_256,

[Code] .....

Example by using the function

EXEC OpenKeys

-- Encrypting
SELECT Encrypt(myColumn) FROM myTable

-- Decrypting
SELECT Decrypt(myColumn) FROM myTable

When I ran the last command :

-- Decrypting
SELECT Decrypt(myColumn) FROM myTable

I get the following error :

Msg 257, Level 16, State 3, Line 2
Implicit conversion from data type nvarchar to varbinary is not allowed. Use the CONVERT function to run this query.

Where will I use the convert function, in decrypt function or in select statement?

View 9 Replies View Related

Problem With Registry Keys While Trying To Install SQL Server 2005 Express

Oct 7, 2007

I've been trying to re-install VS2005 & MS SQL Server express, and I've hit a snag trying to install SQL Server express.

I started by trying to use the automatic uninstaller for VS and had problems so I tried manually uninstalling it (bad idea), which didn't work either, so I re-installed VS completely, then uninstalled it using the automatic uninstaller. I then tried installing, which worked for VS2005, but it didn't work for SQL Server. I've tried 3 times now, and each time it says SQL Server 2005 failed to install.

I checked the summary.txt log found in C:Program FilesMicrosoft SQL Server90Setup BootstrapLOG and from what I understand, it seems that I don't have priveledges to change some registry keys. This has me really lost because I'm installing as Administrator, as you can see from the log below, so I should have access to the registry. Administrator is the only account on the computer so I know I haven't messed up priveledges from another account.

I've included the contents of the summary log below if anyone can make any sense of it and has any ideas I can try.




Code Block

Microsoft SQL Server 2005 9.00.3042.00
==============================
OS Version : Microsoft Windows XP Professional Service Pack 2 (Build 2600)
Time : Sun Oct 07 10:12:41 2007

MRAWESOME : To change an existing instance of Microsoft SQL Server 2005 to a different edition of SQL Server 2005, you must run SQL Server 2005 Setup from the command prompt and include the SKUUPGRADE=1 parameter.
Machine : MRAWESOME
Product : Microsoft SQL Server Setup Support Files (English)
Product Version : 9.00.3042.00
Install : Successful
Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SQLSupport_1.log
--------------------------------------------------------------------------------
Machine : MRAWESOME
Product : Microsoft SQL Server Native Client
Product Version : 9.00.3042.00
Install : Successful
Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SQLNCLI_1.log
--------------------------------------------------------------------------------
Machine : MRAWESOME
Product : Microsoft SQL Server VSS Writer
Product Version : 9.00.3042.00
Install : Successful
Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SqlWriter_1.log
--------------------------------------------------------------------------------
Machine : MRAWESOME
Product : MSXML 6.0 Parser (KB933579)
Product Version : 6.10.1200.0
Install : Successful
Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_MSXML6_1.log
--------------------------------------------------------------------------------
Machine : MRAWESOME
Product : SQL Server Database Services
Error : SQL Server Setup failed to modify security permissions on registry key SOFTWAREMicrosoftMicrosoft SQL Server90Replication for user Administrator. To proceed, verify that the account and domain running SQL Server Setup exist, that the account running SQL Server Setup has administrator privileges, and that the registry key exists on the destination drive.
--------------------------------------------------------------------------------
Machine : MRAWESOME
Product : SQL Server Database Services
Error : SQL Server Setup failed to modify security permissions on registry key SOFTWAREMicrosoftMicrosoft SQL Server90Replication for user Administrator. To proceed, verify that the account and domain running SQL Server Setup exist, that the account running SQL Server Setup has administrator privileges, and that the registry key exists on the destination drive.
--------------------------------------------------------------------------------
Machine : MRAWESOME
Product : Microsoft SQL Server 2005 Express Edition
Product Version : 9.00.1399.06
Install : Failed
Log File : C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SQL.log
Last Action : InstallFinalize
Error String : SQL Server Setup failed to modify security permissions on registry key SOFTWAREMicrosoftMicrosoft SQL Server90Replication for user Administrator. To proceed, verify that the account and domain running SQL Server Setup exist, that the account running SQL Server Setup has administrator privileges, and that the registry key exists on the destination drive.
Error Number : 29508
--------------------------------------------------------------------------------

SQL Server Setup failed. For more information, review the Setup log file in %ProgramFiles%Microsoft SQL Server90Setup BootstrapLOGSummary.txt.


Time : Sun Oct 07 10:18:00 2007


List of log files:
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_Core(Patched).log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SQLSupport_1.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SQLNCLI_1.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SqlWriter_1.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_MSXML6_1.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SQL.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_Datastore.xml
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_.NET Framework 2.0.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_Support.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_Core.log
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGSummary.txt
C:Program FilesMicrosoft SQL Server90Setup BootstrapLOGFilesSQLSetup0004_MRAWESOME_SCC.log

View 1 Replies View Related

Express Will Not Load. Insurmountable Difficulties With Order Of Uninstalls/order Of Installs/ Suggestions Plz

Jan 7, 2007

Finding the "pieces of information" I need to successfully install the SQL Server Express edition is so complex. Uninstalls do "not" really uninstall completely, leading to failure of SQL install. Can you suggest a thorough, one-stop site for directions for the order of app uninstalls and then the order for app installs for the following...

SQL Server Express edition

Visual Studios 2005

Jet 4.0 newest upgrade

.Net Framework 2.0 (or should I use 3.0)

VS2005 Security upgrade

Anything else I need for just creating a database for my VS2005 Visual Basic project?

I was trying to use MS Access as my backend db but would like to try SQL Express



Thank you, Mark





View 7 Replies View Related

Conditional Order By - Sort Result Set By Employee Number Ascending Order

Sep 24, 2012

In SQL sERVER 2008, I have two fields - Depatment and Employees. I need to sort the result set by employee number ascending order, with following exception

1)when department number = 50 - the preferred order is Employee # - 573 followed by 551-572 (employee # belong to Dept 50 = 551-573)

2)When Department number = 20 – the preferred sort order is Employee # 213-220, followed by Employee # 201-213 (employee # belong to Dept 20 = 201-220)

How shall I achieve this?

View 4 Replies View Related

Analysis :: Order Of Rows In Tabular Table Not In Same Order Data Was Retrieved?

May 19, 2015

I never paid much attention to this before but I noticed this today in a new table I was creating.

For tables defined in the tabular model the table properties have something like SELECT Blah FROM TableName ORDER BY Blah Then in the tabular model the table's data is in the same order it was ordered by in the data source for the table.

I have a date table I setup and I noticed it is NOT respecting the sort order.

I have it sorted by DateID which sorts with the oldest date first and newest date as last row.However, the table that is imported and stored in the data model is not in that order.

I can of course manually sort the rows in BIDS/DataTools, but I find this discrepancy odd.

Would this have negative impacts on the EARLIER function for example if the data rows are not in the order specified?

View 8 Replies View Related

Calculate Total Amount Of Order Details Based On Particular Order

Apr 10, 2014

I have a query that calculate the total amount of order details based on a particular order:

Select a.OrderID,SUM(UnitPrice*Quantity-Discount)
From [Order Details]
Inner Join Orders a
On a.OrderID=[Order Details].OrderID
Group by a.OrderID

My question is what if I wanted to create a formula to something like:

UnitPrice * Quantity - DiscountAmount Where DiscountAmount = UnitPrice Quantity * Discount

Do I need to create a function for that? Also is it possible to have m y query as a table variable?

View 7 Replies View Related

Default Sort Order - Open Table - Select Without Order By

Mar 27, 2008

Hi!

I recently run into a senario when a procedure quiered a table without a order by clause. Luckily it retrived data in the prefered order.

The table returns the data in the same order in SQL Manager "Open Table"

So I started to wonder what deterimins the sort order when there is no order by clause ?

I researched this for a bit but found no straight answers. My table has no PK, but an identiy column.

Peace.

/P

View 5 Replies View Related

How To Add Order Item Into A Purchase Order Using A Stored Procedure/Trigger?

Jan 4, 2008

Hey guys, i need to find out how can i add order items under a Purchase Order number.
My table relationship is PurchaseOrder ->PurchaseOrderItem.

below is a Stored Procedure that i have wrote in creating a PO:



CREATE PROC spCreatePO (@SupplierID SmallInt, @date datetime, @POno SmallInt OUTPUT)

AS

BEGIN

INSERT INTO PurchaseOrder (PurchaseOrderDate, SupplierID) VALUES(@date, @SupplierID)

END



SET @POno = @@IDENTITY

RETURN


However, how do i make it that it will automatically adds item under the POno being gernerated? can i use a trigger so that whenever a Insert for PO is success, it automaticallys proceed to adding the items into the table PurcahseOrderItem?


CREATE TRIGGER trgInsertPOItem

ON PurchaseOrderItem

FOR INSERT

AS

BEGIN


'What do i entered???'
END

RETURN


help is needed asap! thanks!

View 14 Replies View Related







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