Showing posts with label key. Show all posts
Showing posts with label key. Show all posts

Sunday, March 11, 2012

Can it be a bug in SQL CE?

Hi!

I use SQL CE with VS.NET 2003. I find the following bug second time.

The table has an "ID int IDENTITY(0,1) PRIMARY KEY,". That is my row identity.

I add rows to the table, then I made some select and update queries. Then I realized that the ID order not in the general order (from 0 to ........)

For example: 6,7,8,0,1,2,3,4,5.

Of course row 6,7 and 8 was added the very last.

The content of each row is not mixed, only the ID order.

Is it a very confused, because we develop mobile invoice programs for PDAs.

What I did wrong?

Thank you!

Do you mean rows are not sorted by ID should you retrieve them with select or IDs are created not in order of insertions? Say, you have integer column in addition to ID, and you've inserted numbers from 0 to 3 into it. Do you get data like this:

2 2

1 1

0 0

3 3

Or like this:

2 0

1 1

0 2

3 3

|||

Duplicate thread from the same user: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=229153&SiteID=1

Follow only the above given thread. This thread will not be monitored any more.

Thanks,

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

Thursday, March 8, 2012

Can I use Unicode as Primary Key? For example, Chinese Character. <eom>

Can I use Unicode as Primary Key? For example, Chinese Character. <eom>Sean
Any reasons? Please read "Defining a Primary Key" article in the BOL.
"Sean" <ventilla@.hotmail.com> wrote in message
news:%23ecL5hvKGHA.744@.TK2MSFTNGP09.phx.gbl...
>|||Yes. Any CHAR/NCHAR/VARCHAR/NVARCHAR column(s) upto 900 bytes total
size. In SQL Server 2005 you cannot use the (N)VARCHAR(MAX) datatype as
a key.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||Thanks a lot!
But when I link the database using Access Database, all the records with
Chinese character will appears as "#Deleted" in the table in Access. What is
wrong? Any idea?
Thanks again.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1139218262.315786.78000@.g47g2000cwa.googlegroups.com...
> Yes. Any CHAR/NCHAR/VARCHAR/NVARCHAR column(s) upto 900 bytes total
> size. In SQL Server 2005 you cannot use the (N)VARCHAR(MAX) datatype as
> a key.
> --
> David Portas, SQL Server MVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>|||Sean
As David has mentioned you should use NVARCHAR(n)/NACHAR(n) datatype to
transfer unicode characters
CREATE TABLE #Test (Col NCHAR(12))
DECLARE @.nstring nchar(12)
SET @.nstring = N'?kergatan 24'
INSERT INTO #Test VALUES (@.nstring )
"Sean" <ventilla@.hotmail.com> wrote in message
news:edGjTJwKGHA.2304@.TK2MSFTNGP15.phx.gbl...
> Thanks a lot!
> But when I link the database using Access Database, all the records with
> Chinese character will appears as "#Deleted" in the table in Access. What
> is wrong? Any idea?
> Thanks again.
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> news:1139218262.315786.78000@.g47g2000cwa.googlegroups.com...
>|||One of my customer enters Chinese characters as the primary key.
That's why I am headache now.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:eZKNNlvKGHA.3896@.TK2MSFTNGP15.phx.gbl...
> Sean
> Any reasons? Please read "Defining a Primary Key" article in the BOL.
>
>
> "Sean" <ventilla@.hotmail.com> wrote in message
> news:%23ecL5hvKGHA.744@.TK2MSFTNGP09.phx.gbl...
>

Saturday, February 25, 2012

Can I use keyword Like with a Parameter

Should be simple. I'm writing a report to find employees by last name.

I want the user to key in at least a few characters of the last name and the report will search for all last names that are like that.

I know in TSQL it would go:

Last_name like 'Jones%'

But how do I set up a parameter in Reporting Services

I've tried:

last_name like =@.name%

Any ideas?

Thanks,

Jim

Any ideas? Can the Keyword "Like" be used to find similar occurences of a user entered parameter...|||Within the dataset query you can declare a variable that references the parameter with the text then append the necessary % to the end. So the reference would look something like...

DECLARE @.some_variable NVARCHAR(40)
SET @.some_variable = @.parameter_field_text + '%'

You can then use this...

SELECT *
FROM some_view
WHERE NameField LIKE @.some_variable|||

You would probably need to use dynamic sql and expression.

="Select * from table1 where last_name like '" + @.name + "%'"

Or use a stored procedure and perform the like statement within it.

cheers,

Andrew

Thursday, February 16, 2012

can I reset tbl ID to 1

I have a table in my db that has an identity column as the primary key. I have deleted all the data and have tried to use truncate table on it to reset the identity column. The table has a number of foreign key constraints so it will not truncate.

Is there any way to reset the indentity column without removing the constraints?

Hi Jack,

You can reset the seed of the identity using DBCC CHECKIDENT.

See this link for more info:

Resetting IDENTITY

Can I reserve all the rows in Fact table when add the dimension in cube

My fact table join with a dimension table with a foreign key.
But there some foreign key in the fact table which doesn't exist in the
dimension table.
When I add the dimension in cube, all no match rows will be filtered out
Can I reserve all the rows in Fact table when add the dimension in cube?
I'd suggest that as a part of your data load you establish a process which
selects all the foreign keys from fact table that are not found in the
dimension and add them to the datasource for dimension (it can be a table or
a view). Then your dimension and cube will be consistent
Regards,
Ilona Shulman
Senior Development Consultant, DBA
SSE Inc
http://www.sseinc.com
"ad" <ad@.wfes.tcc.edu.tw> wrote in message
news:elh4y1lqEHA.1728@.TK2MSFTNGP10.phx.gbl...
> My fact table join with a dimension table with a foreign key.
> But there some foreign key in the fact table which doesn't exist in the
> dimension table.
> When I add the dimension in cube, all no match rows will be filtered out
> Can I reserve all the rows in Fact table when add the dimension in cube?
>
|||Analysis Services dislike bad data quality.
so you have to insure that all your keys in your fact table exists in your
dimension.
Generally we create an "unknown" member in the dimension.
For example, the key "-1" is the unknown dimension member.
Then every row in the fact table as the -1 as the default value, so if the
dimension member doesn't exists, your fact table contain -1 and can be used
in the cube.
Change your ETL process to do this job.
"ad" <ad@.wfes.tcc.edu.tw> a crit dans le message de news:
elh4y1lqEHA.1728@.TK2MSFTNGP10.phx.gbl...
> My fact table join with a dimension table with a foreign key.
> But there some foreign key in the fact table which doesn't exist in the
> dimension table.
> When I add the dimension in cube, all no match rows will be filtered out
> Can I reserve all the rows in Fact table when add the dimension in cube?
>

Tuesday, February 14, 2012

Can I register my evaluation copy to full blown version using product key?

I installed the evaluation copy remotely and wish to register the product by entering its product key, would that possible since I don't have the cd in the box.

Matt

Unfortunately you cannot just enter the new product key. The upgrade in edition is treated as a product upgrade.


This blog should answer all your questions about this upgrade - http://blogs.msdn.com/sqlblog/archive/2006/09/17/upgrade-eval-edtion-to-full-blow-sql-2005-editions.aspx

Thanks,
Sam Lester (MSFT)

Can I Query a Form?

I currently have a form setup to read a table display information from the table depending of what primary key is being chosen on the form.
When the primary key is picked, the rest of fields on the form are auto populated.
What I want to do is have a query run to obtain the information off of the form, so that a report can be run off of the query. However, maybe I am going about this the long way? The reason is because when I attempt to run the report directly off of the form, none of the fields are entered, I simply get blanks in the form fields.

Is it possible, and do I need to go with option 1? Or is there an easier way to accomplish this?This might be a little more than you asked for but the concept still works for just one key field instead of many fields to limit the search.

The free downloadable sample database at www.bullschmidt.com/access uses the query by form concept so that on the invoices dialog one can optionally choose a rep, a customer, and perhaps a date range, click on a button that says "Input," and then have the invoice form open up showing all the invoices that match the criteria.

And here is how the query by form concept can work.

On the invoices dialog there are the following controls:
InvDateMin with DefaultValue of =DateSerial(Year(Date())-1,1,1)
InvDateMax with DefaultValue of =Date()
InvRepNum with DefaultValue of *
InvCustNum with DefaultValue of *

Also on the invoices dialog there is a command button called cmdInput to open the invoices form with the following code behind the OnClick property:
DoCmd.OpenForm "frmInv"

And of course there could be a button to open a report the same way:
DoCmd.OpenReport "rptInv", acViewPreview

The invoices form (frmInv) has RecordSource property of qryInv.

And the qryInv query's criteria for the InvDate field has:
Between [Forms]![frmInvDialog]![InvDateMin] And [Forms]![frmInvDialog]![InvDateMax]

And the qryInv query's criteria for the RepNum field has:
Like [Forms]![frmInvDialog]![InvRepNum]

And the qryInv query's criteria for the CustNum field has:
Like [Forms]![frmInvDialog]![CustNum]

One related point is that you probably wouldn't want to allow blanks (i.e. Nulls) in fields that are going to be used with Like in any criteria for that field. Otherwise the blanks wouldn't be shown. And to counter that you might consider creating the query's SQL statement dynamically so that the criteria on a particular field isn't used unless needed.