Showing posts with label written. Show all posts
Showing posts with label written. Show all posts

Tuesday, March 27, 2012

Help with Collation - Decoding the Compatibility Designator

We have a 3rd-party written application that was installed and has
been upgraded on the same server. We want to move the database to a
SAN, but it has a compatibility collation. The select
serverproperty(N'Collation') command returns:
Compatibility_52_409_20001. I have been reading about decoding this
compatibility designator, but I'm stuck. I know the 52 refers to
Dictionary Order, case-insensitive, for use with 1252 character set.
The 409 is hex 0x409 or 1033, which translates to General Unicode.
From what I've read, the 20001 is also hex which means it is 0x20001
or 131073.
Anyone have any idea what the 131073 translation is? I'd like to know
what collation sequence to choose when installing SQL 2000 to match up
with this.
Any help greatly appreciated.
Thanks,
BillThere's some more info on this in 270042 INF: Description of SQL Server
Compatibility Collations (http://support.microsoft.com/?id=270042).
Here are the bits that make up the last portion of a compatibility
collation name:
+===============+=============+==================+
| Style | Value (Hex) | Value (Decimal) |
+===============+=============+==================+
| Ignore case | 0x00001 | 1 |
+===============+=============+==================+
| Ignore accent| 0x00002 | 2 |
+===============+=============+==================+
| Ignore Kana | 0x10000 | 65536 |
+===============+=============+==================+
| Ignore width | 0x20000 | 131072 |
+===============+=============+==================+
131073 is 131072 (ignore width) + 1 (ignore case). So this collation is
accent-sensitive, kana-sensitive, case-insensitive, width-insensitive.
> I'd like to know what collation sequence to choose
> when installing SQL 2000 to match up with this.
You cannot select a compatibility collation during a clean interactive SQL
2000 setup; you can only choose one of the so-called "named collations".
Your options here are:
- Install a SQL 7.0 instance with the same collation properties and do an
in place upgrade of this instance to SQL 2000. An in-place instance
upgrade always retains the existing collation settings, even if they are
non-standard.
- Use DTS to move the data in this database to a db with a more standard
collation that you can select as an instance-level collation when
installing SQL 2K.
- Modify stored procs that join temp tables to user tables to add a
"COLLATE database_default" to the column definition of temp table
char/varchar columns. In most apps there just a handful of these
modifications are required, and one benefit of this approach is that the
app will be "system collation agnostic" from that point forward and can be
successfully run in a mixed collation evironment or on any other server.
- Do a silent install of SQL 2000. Unlike an interactive install, for a
silent install you can specify any collation name in the .ISS file, even if
it is a compatibility collation.
HTH,
Bart
--
Please reply to the newsgroup only - thanks.
This posting is provided "AS IS" with no warranties, and confers no rights.
From: bengels@.wi.rr.com (Bill Engels)
Newsgroups: microsoft.public.sqlserver.server
Subject: Help with Collation - Decoding the Compatibility Designator
Date: 31 Oct 2003 11:32:42 -0800
Organization: http://groups.google.com
Lines: 19
Message-ID: <7b42351f.0310311132.4c922d38@.posting.google.com>
NNTP-Posting-Host: 204.87.60.232
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1067628762 19180 127.0.0.1 (31 Oct 2003
19:32:42 GMT)
X-Complaints-To: groups-abuse@.google.com
NNTP-Posting-Date: Fri, 31 Oct 2003 19:32:42 +0000 (UTC)
Path:
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.su
l.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!po
stnews1.google.com!not-for-mail
Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:314087
X-Tomcat-NG: microsoft.public.sqlserver.server
We have a 3rd-party written application that was installed and has
been upgraded on the same server. We want to move the database to a
SAN, but it has a compatibility collation. The select
serverproperty(N'Collation') command returns:
Compatibility_52_409_20001. I have been reading about decoding this
compatibility designator, but I'm stuck. I know the 52 refers to
Dictionary Order, case-insensitive, for use with 1252 character set.
The 409 is hex 0x409 or 1033, which translates to General Unicode.
From what I've read, the 20001 is also hex which means it is 0x20001
or 131073.
Anyone have any idea what the 131073 translation is? I'd like to know
what collation sequence to choose when installing SQL 2000 to match up
with this.
Any help greatly appreciated.
Thanks,
Bill|||Thanks for the help Bart. Appreciate the answer and ALL your help in the newsgroups.
Bill

Friday, March 23, 2012

Help with a trigger

I have written the following trigger

alter trigger updatecustomerorderreleasedatewhenstatusisreleased
on CUSTOMER_ORDER
after update
as

declare
@.CUST_ORDER_ID VARCHAR(15)

select @.CUST_ORDER_ID = ID from customer_order
if update(STATUS)
insert into CUSTER_ORDER_RELEASE_DATE
(CUSTOMER_ORDER_ID,RELEASE_DATE)
values (@.CUST_ORDER_ID,getdate())

It always returns the same ID from customer_order not the one that is
changing status. What am I missing?[posted and mailed, please reply in news]

ANDY PHILLEY (APHILLEY@.WATSONFURNITURE.COM) writes:
> alter trigger updatecustomerorderreleasedatewhenstatusisreleased
> on CUSTOMER_ORDER
> after update
> as
> declare
> @.CUST_ORDER_ID VARCHAR(15)
> select @.CUST_ORDER_ID = ID from customer_order
> if update(STATUS)
> insert into CUSTER_ORDER_RELEASE_DATE
> (CUSTOMER_ORDER_ID,RELEASE_DATE)
> values (@.CUST_ORDER_ID,getdate())
> It always returns the same ID from customer_order not the one that is
> changing status. What am I missing?

You are reading the customer_order table with out a WHERE clause. SQL
Server will retrieve all rows, and the variable with recieve the last
value returned. Since there is no ORDER BY clause, this can be any
value in the table, although it's not truly random. It is not unlikely
that it is always the same row.

If you want to know rows that were affected, you should use the
the virtual tables "inserted" and "deleted". They hold the the after-
image and the before-image respectivly of the updated rows. Note that
since a trigger fire once per statement, there can be several rows in
the tables.

Your trigger should probably read:

CREATE TRIGGER trg ON CUSTOMER_ORDER AFTER UPDATE AS
IF UPDATE(STATUS)
INSERT CUSTOMER_ORDER_RELEASE_DATE (CUSTOMER_ORDER_ID, RELEASE_DATE)
SELECT i.ID, getdate()
FROM inserted i
JOIN deleted d ON i.ID = d.ID
WHERE i.STATUS = 'Relased'
AND d.STATUS = 'Something else'

I've here also taken care of the case that Status may be updated, but
not change.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Friday, March 9, 2012

Help w/ unique identity

Not sure if I have the right term in my Subject, but I have written an
application using VB6, which stores employee transactions in a SQL database.
I had originally designed the app for independent use in a standalone PC in
our remote offices but was then asked to expand its use to our corporate
office and import the transactions from all the locations into one database.
I have an Identity column in my table labeled "TransactionID" with the
Identity Seed and Indentity Increment set to the default of 1 and
automatically increments. The TransactionID number ensures that each
transaction is unique because other pieces of data collected in the table
could be the same such as StoreNumber, EmployeeNumber, etc.
All this is working fine, but now I want to import the transactions from the
remote location(s) into the SQL database at the corporate office. Now, there
is the very real possibility that a TransactionID from any of the remote
locations will match. Plus, when I import the records into the corporate
database, won't the master database want to reassign it a TransactionID as
well?
Since the TransactionID is unique at each store/office level, I was thinking
of formatting the TransactionID to something like "1234.01" where "1234" is
the next row in the table and "01" is the store number. This would be
separated by a decimal point. The store number would never exceed 2 digits
and the corporate office could be "00" or "99".
Is this possible or is there a better way to do this? I need to preserve the
TransactionID from the store/office because I use it to create an audit
trail if a transaction is ever modified.
Thanks,
BarryYou can add StoreID to the table and keep current Identity column as it (int
).
Perayu
"BCS" wrote:

> Not sure if I have the right term in my Subject, but I have written an
> application using VB6, which stores employee transactions in a SQL databas
e.
> I had originally designed the app for independent use in a standalone PC i
n
> our remote offices but was then asked to expand its use to our corporate
> office and import the transactions from all the locations into one databas
e.
> I have an Identity column in my table labeled "TransactionID" with the
> Identity Seed and Indentity Increment set to the default of 1 and
> automatically increments. The TransactionID number ensures that each
> transaction is unique because other pieces of data collected in the table
> could be the same such as StoreNumber, EmployeeNumber, etc.
> All this is working fine, but now I want to import the transactions from t
he
> remote location(s) into the SQL database at the corporate office. Now, the
re
> is the very real possibility that a TransactionID from any of the remote
> locations will match. Plus, when I import the records into the corporate
> database, won't the master database want to reassign it a TransactionID as
> well?
> Since the TransactionID is unique at each store/office level, I was thinki
ng
> of formatting the TransactionID to something like "1234.01" where "1234" i
s
> the next row in the table and "01" is the store number. This would be
> separated by a decimal point. The store number would never exceed 2 digits
> and the corporate office could be "00" or "99".
> Is this possible or is there a better way to do this? I need to preserve t
he
> TransactionID from the store/office because I use it to create an audit
> trail if a transaction is ever modified.
> Thanks,
> Barry
>
>|||I suggest you add another field in the table called store id
modify the unique constraint or the Pk to a composite (PK) or constraint
a composite pk is composed of at least two or more fields. In that way
you still preserve uniquesness of the data without violation atomicity of
the column
or better known as the domain integrity
Jose de Jesus Jr. Mcp,Mcdba
Data Architect
Sykes Asia (Manila philippines)
MCP #2324787
"BCS" wrote:

> Not sure if I have the right term in my Subject, but I have written an
> application using VB6, which stores employee transactions in a SQL databas
e.
> I had originally designed the app for independent use in a standalone PC i
n
> our remote offices but was then asked to expand its use to our corporate
> office and import the transactions from all the locations into one databas
e.
> I have an Identity column in my table labeled "TransactionID" with the
> Identity Seed and Indentity Increment set to the default of 1 and
> automatically increments. The TransactionID number ensures that each
> transaction is unique because other pieces of data collected in the table
> could be the same such as StoreNumber, EmployeeNumber, etc.
> All this is working fine, but now I want to import the transactions from t
he
> remote location(s) into the SQL database at the corporate office. Now, the
re
> is the very real possibility that a TransactionID from any of the remote
> locations will match. Plus, when I import the records into the corporate
> database, won't the master database want to reassign it a TransactionID as
> well?
> Since the TransactionID is unique at each store/office level, I was thinki
ng
> of formatting the TransactionID to something like "1234.01" where "1234" i
s
> the next row in the table and "01" is the store number. This would be
> separated by a decimal point. The store number would never exceed 2 digits
> and the corporate office could be "00" or "99".
> Is this possible or is there a better way to do this? I need to preserve t
he
> TransactionID from the store/office because I use it to create an audit
> trail if a transaction is ever modified.
> Thanks,
> Barry
>
>|||> Since the TransactionID is unique at each store/office level, I was thinkingd">
> of formatting the TransactionID to something like "1234.01" where "1234" i
s
> the next row in the table and "01" is the store number. This would be
> separated by a decimal point. The store number would never exceed 2 digits
> and the corporate office could be "00" or "99".
I can not understand well because you are mixing names here.
My recommendation is to add a new column to the transaction table, to store
the [store] from where the transaccion was made. Do not use the formatting
approach (1234.01), then you will have to parse it into a select statement
and this will avoid sql server from considering it as a search argument.
Also, you can not create indexes based on a formula unless you create a
computed column and base the index on this column.
avoid this:
select c1,..., cn
from dbo.[transactions]
where right(transactionid, 2) = '01'
AMB
"BCS" wrote:

> Not sure if I have the right term in my Subject, but I have written an
> application using VB6, which stores employee transactions in a SQL databas
e.
> I had originally designed the app for independent use in a standalone PC i
n
> our remote offices but was then asked to expand its use to our corporate
> office and import the transactions from all the locations into one databas
e.
> I have an Identity column in my table labeled "TransactionID" with the
> Identity Seed and Indentity Increment set to the default of 1 and
> automatically increments. The TransactionID number ensures that each
> transaction is unique because other pieces of data collected in the table
> could be the same such as StoreNumber, EmployeeNumber, etc.
> All this is working fine, but now I want to import the transactions from t
he
> remote location(s) into the SQL database at the corporate office. Now, the
re
> is the very real possibility that a TransactionID from any of the remote
> locations will match. Plus, when I import the records into the corporate
> database, won't the master database want to reassign it a TransactionID as
> well?
> Since the TransactionID is unique at each store/office level, I was thinki
ng
> of formatting the TransactionID to something like "1234.01" where "1234" i
s
> the next row in the table and "01" is the store number. This would be
> separated by a decimal point. The store number would never exceed 2 digits
> and the corporate office could be "00" or "99".
> Is this possible or is there a better way to do this? I need to preserve t
he
> TransactionID from the store/office because I use it to create an audit
> trail if a transaction is ever modified.
> Thanks,
> Barry
>
>|||I already have a StoreNumber column, so I guess I just need to find some
info on constructing a Composite Constraint. Any good links?
Thanks,
Barry
<Jose G. de Jesus Jr MCP>; "MCDBA" <Email me> wrote in message
news:EF3BF399-EDA4-4652-BC12-4321B73497D2@.microsoft.com...
> I suggest you add another field in the table called store id
> modify the unique constraint or the Pk to a composite (PK) or constraint
> a composite pk is composed of at least two or more fields. In that way
> you still preserve uniquesness of the data without violation atomicity of
> the column
> or better known as the domain integrity
>
> --
>
> Jose de Jesus Jr. Mcp,Mcdba
> Data Architect
> Sykes Asia (Manila philippines)
> MCP #2324787
>
> "BCS" wrote:
>
database.
in
database.
table
the
there
as
thinking
is
digits
the|||
> locations will match. Plus, when I import the records into the corporate
> database, won't the master database want to reassign it a TransactionID as
> well?
>
You didn't mention, but I'm assuming that records in this table are only
inserted at the store level and are consolidated at the corporate level for
accounting and reporting purposes. The corporate data model can have the
same basic column layout as the store level model, but do not use the
identity property for TransactionID, becuase there is no need for it and
would create problem when importing.

> Since the TransactionID is unique at each store/office level, I was
> thinking
> of formatting the TransactionID to something like "1234.01" where "1234"
> is
> the next row in the table and "01" is the store number. This would be
> separated by a decimal point. The store number would never exceed 2 digits
> and the corporate office could be "00" or "99".
>
Identity columns (in this case TransactionID) must be integers, and you
cannot alter their format.

> Is this possible or is there a better way to do this? I need to preserve
> the
> TransactionID from the store/office because I use it to create an audit
> trail if a transaction is ever modified.
>
The combination of TransactionID and StoreID would make each transaction
unique at the corporate level, and this would be a good candidate for the
primary key at both the store and corporate level. When your primary key is
an identoty key, you should attempt to identify a natural key (ex: StoreID,
RegisterID, TransactionDateTime) and place a unique constraint on it.

> Thanks,
> Barry
>|||He probably means that the primary key should be composed of more than 1
column. For example:
CONSTRAINT [PK_Sales] PRIMARY KEY CLUSTERED
(
[StoreNumber],
[TransactionID]
)
"BCS" <bswedeen@.tayloroil.com> wrote in message
news:rT_Oe.36020$es2.553871@.twister.southeast.rr.com...
>I already have a StoreNumber column, so I guess I just need to find some
> info on constructing a Composite Constraint. Any good links?
> Thanks,
> Barry
> <Jose G. de Jesus Jr MCP>; "MCDBA" <Email me> wrote in message
> news:EF3BF399-EDA4-4652-BC12-4321B73497D2@.microsoft.com...
> database.
> in
> database.
> table
> the
> there
> as
> thinking
> is
> digits
> the
>