How do a change the alternate rows within a group.
ie i am grouping in a product type that also has a product numbers & value
on the same line. Since there is more than 1 product type there is multiple
rows within the group.
I have tried the formula iif(rownumber(nothing) Mod 2, "Red", "White")
But this doesnt seem to work.Although I do not know the answer, perhaps the problem is related to
rownumber(nothing)... I think the rownumber function applies to rows in the
data set... and I wonder if the GROUP lines do not get a rownumber with
(nothing) as the parameter... You might add the function to display in the
group field to check its value...
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Tango" <Tango@.discussions.microsoft.com> wrote in message
news:23069475-AA6E-42BA-9211-321A65D4C3CE@.microsoft.com...
> How do a change the alternate rows within a group.
> ie i am grouping in a product type that also has a product numbers & value
> on the same line. Since there is more than 1 product type there is
> multiple
> rows within the group.
> I have tried the formula iif(rownumber(nothing) Mod 2, "Red", "White")
> But this doesnt seem to work.|||Thanks Wayne,
I would have thought this to be a common problem...
"Wayne Snyder" wrote:
> Although I do not know the answer, perhaps the problem is related to
> rownumber(nothing)... I think the rownumber function applies to rows in the
> data set... and I wonder if the GROUP lines do not get a rownumber with
> (nothing) as the parameter... You might add the function to display in the
> group field to check its value...
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> www.mariner-usa.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and it's
> community of SQL Server professionals.
> www.sqlpass.org
> "Tango" <Tango@.discussions.microsoft.com> wrote in message
> news:23069475-AA6E-42BA-9211-321A65D4C3CE@.microsoft.com...
> > How do a change the alternate rows within a group.
> >
> > ie i am grouping in a product type that also has a product numbers & value
> > on the same line. Since there is more than 1 product type there is
> > multiple
> > rows within the group.
> >
> > I have tried the formula iif(rownumber(nothing) Mod 2, "Red", "White")
> >
> > But this doesnt seem to work.
>
>
Showing posts with label numbers. Show all posts
Showing posts with label numbers. Show all posts
Sunday, March 11, 2012
Friday, February 10, 2012
Autonumber field
Hi there,
Is there a way to have an autonumber field (as in MSAccess) or some sort of
a counter field that automatically numbers records?
Thank you in advance!What version of SQL Server and why do you need it? Whats the usage of that
column? You could use identity property but please explain the usage.
MC
"PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
> Hi there,
> Is there a way to have an autonumber field (as in MSAccess) or some sort
> of
> a counter field that automatically numbers records?
> Thank you in advance!|||Well I'm busy writing a front-end in Access to populate records into an SQL
table. Firstly, the way I understand it, is to have a primary key set up on
one of the fields in order to update this table from an app like Access. But
none of the fields currently in this table can be used for a primary key, so
I've created a counter that must be the primary key. This then must obviously
be some sort of an automated numbered field...
"MC" wrote:
> What version of SQL Server and why do you need it? Whats the usage of that
> column? You could use identity property but please explain the usage.
>
> MC
>
> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
> > Hi there,
> >
> > Is there a way to have an autonumber field (as in MSAccess) or some sort
> > of
> > a counter field that automatically numbers records?
> >
> > Thank you in advance!
>|||Okay. For that, you can use identity property. Usually, declare int column
and set identity. If you want to add it to exeisting table it would be
something like:
alter table Test
add ColumnName int identity(1,1) not null
MC
"PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
news:0585DF2B-3173-44FE-8941-36D9A84C6DAB@.microsoft.com...
> Well I'm busy writing a front-end in Access to populate records into an
> SQL
> table. Firstly, the way I understand it, is to have a primary key set up
> on
> one of the fields in order to update this table from an app like Access.
> But
> none of the fields currently in this table can be used for a primary key,
> so
> I've created a counter that must be the primary key. This then must
> obviously
> be some sort of an automated numbered field...
> "MC" wrote:
>> What version of SQL Server and why do you need it? Whats the usage of
>> that
>> column? You could use identity property but please explain the usage.
>>
>> MC
>>
>> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
>> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
>> > Hi there,
>> >
>> > Is there a way to have an autonumber field (as in MSAccess) or some
>> > sort
>> > of
>> > a counter field that automatically numbers records?
>> >
>> > Thank you in advance!
Is there a way to have an autonumber field (as in MSAccess) or some sort of
a counter field that automatically numbers records?
Thank you in advance!What version of SQL Server and why do you need it? Whats the usage of that
column? You could use identity property but please explain the usage.
MC
"PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
> Hi there,
> Is there a way to have an autonumber field (as in MSAccess) or some sort
> of
> a counter field that automatically numbers records?
> Thank you in advance!|||Well I'm busy writing a front-end in Access to populate records into an SQL
table. Firstly, the way I understand it, is to have a primary key set up on
one of the fields in order to update this table from an app like Access. But
none of the fields currently in this table can be used for a primary key, so
I've created a counter that must be the primary key. This then must obviously
be some sort of an automated numbered field...
"MC" wrote:
> What version of SQL Server and why do you need it? Whats the usage of that
> column? You could use identity property but please explain the usage.
>
> MC
>
> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
> > Hi there,
> >
> > Is there a way to have an autonumber field (as in MSAccess) or some sort
> > of
> > a counter field that automatically numbers records?
> >
> > Thank you in advance!
>|||Okay. For that, you can use identity property. Usually, declare int column
and set identity. If you want to add it to exeisting table it would be
something like:
alter table Test
add ColumnName int identity(1,1) not null
MC
"PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
news:0585DF2B-3173-44FE-8941-36D9A84C6DAB@.microsoft.com...
> Well I'm busy writing a front-end in Access to populate records into an
> SQL
> table. Firstly, the way I understand it, is to have a primary key set up
> on
> one of the fields in order to update this table from an app like Access.
> But
> none of the fields currently in this table can be used for a primary key,
> so
> I've created a counter that must be the primary key. This then must
> obviously
> be some sort of an automated numbered field...
> "MC" wrote:
>> What version of SQL Server and why do you need it? Whats the usage of
>> that
>> column? You could use identity property but please explain the usage.
>>
>> MC
>>
>> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
>> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
>> > Hi there,
>> >
>> > Is there a way to have an autonumber field (as in MSAccess) or some
>> > sort
>> > of
>> > a counter field that automatically numbers records?
>> >
>> > Thank you in advance!
Autonumber field
Hi there,
Is there a way to have an autonumber field (as in MSAccess) or some sort of
a counter field that automatically numbers records?
Thank you in advance!
Well I'm busy writing a front-end in Access to populate records into an SQL
table. Firstly, the way I understand it, is to have a primary key set up on
one of the fields in order to update this table from an app like Access. But
none of the fields currently in this table can be used for a primary key, so
I've created a counter that must be the primary key. This then must obviously
be some sort of an automated numbered field...
"MC" wrote:
> What version of SQL Server and why do you need it? Whats the usage of that
> column? You could use identity property but please explain the usage.
>
> MC
>
> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
>
Is there a way to have an autonumber field (as in MSAccess) or some sort of
a counter field that automatically numbers records?
Thank you in advance!
Well I'm busy writing a front-end in Access to populate records into an SQL
table. Firstly, the way I understand it, is to have a primary key set up on
one of the fields in order to update this table from an app like Access. But
none of the fields currently in this table can be used for a primary key, so
I've created a counter that must be the primary key. This then must obviously
be some sort of an automated numbered field...
"MC" wrote:
> What version of SQL Server and why do you need it? Whats the usage of that
> column? You could use identity property but please explain the usage.
>
> MC
>
> "PsyberFox" <PsyberFox@.discussions.microsoft.com> wrote in message
> news:B6BD5C03-55C4-4FAB-A318-DB0763F0978D@.microsoft.com...
>
Labels:
automatically,
autonumber,
database,
field,
microsoft,
msaccess,
mysql,
numbers,
ofa,
oracle,
recordsthank,
server,
sort,
sql
AutoNumber Column and ...
Hi *.*
I plan to crate a database and want to know if it's good to use autonumber
columns as my primary key or I should generate the numbers myself?
Also, If I want to replicate the DB, is it ok to use autonumber columns?
At last, Is there any way I can manage the autonumber start number? Means
autonumbering starts at 100 or 300000 instead of 0?
Thanks for your help,
HOA
Hoa wrote:
> Hi *.*
> I plan to crate a database and want to know if it's good to use autonumber
> columns as my primary key or I should generate the numbers myself?
> Also, If I want to replicate the DB, is it ok to use autonumber columns?
> At last, Is there any way I can manage the autonumber start number? Means
> autonumbering starts at 100 or 300000 instead of 0?
> Thanks for your help,
> HOA
>
I suggest you take a step back and spend a month researching all this
along with getting your database professionally designed. Every one of
those questions are so "depends" in nature that the very fact that you
asked them tells me you don't have a good enough grasp of the situation
to appreciate the answers.
But, quickly:
1) Depends.
2) Sorta. Depends.
3) Yes.
There is an entire section in the Books Online that is called
"Replication Data Considerations" with a topic "Using IDENTITY Values".
Have you not even bothered to read that section prior to posting your
very open ended question?
Zach
|||Identity columns are fine for PK... as long as you plan on keeping your identity values unique. PK values MUST be unique; Identity does not explicitly enforce uniqueness. Identity columns are good for PKs in the fact that they are INTEGER datatype. This d
atatype is small, so it works well w/ indexes (PK defaults to unique, clustered)
Identity columns may need to be set to 'NOT FOR REPLICATION' in certain situations. See Books Online: Replication topology & NOT FOR REPLICATION for more info.
Yes, you can start an Identity value at a number greater than 0 or 1... you declare it with the IDENTITY(10,5) clause (10 being the 'seed' value, 5 being the increment.
"Hoa" wrote:
> Hi *.*
> I plan to crate a database and want to know if it's good to use autonumber
> columns as my primary key or I should generate the numbers myself?
> Also, If I want to replicate the DB, is it ok to use autonumber columns?
> At last, Is there any way I can manage the autonumber start number? Means
> autonumbering starts at 100 or 300000 instead of 0?
> Thanks for your help,
> HOA
>
>
|||Oh boy. Books Online is your friend, don't let it be a stranger. These
issues are all covered in the documentation.
Your choice of a primary key depends on more factors than "it's good"... see
for a bit of my own opinion.
Using an IDENTITY in a replication scenario is okay, depending on what type
of replication. It will not work in merge replication, for example, since
IDENTITY can't guarantee uniqueness from two different database sources.
As for the identity, yes see the CREATE TABLE and DBCC CHECKIDENT tables in
Books Online. If the table hasn't been created:
CREATE TABLE Splunge
(sid INT IDENTITY(30000, 1))
INSERT Splunge DEFAULT VALUES
INSERT Splunge DEFAULT VALUES
SELECT * FROM Splunge
GO
DROP TABLE Splunge
Once again, please become familiar with Books Online. All of the questions
are answered, and then some, in the documentation you already have available
to you.
http://www.aspfaq.com/
(Reverse address to reply.)
"Hoa" <newpoorguy@.yahoo.com> wrote in message
news:eMTZ#DkeEHA.2804@.TK2MSFTNGP11.phx.gbl...
> Hi *.*
> I plan to crate a database and want to know if it's good to use
autonumber
> columns as my primary key or I should generate the numbers myself?
> Also, If I want to replicate the DB, is it ok to use autonumber columns?
> At last, Is there any way I can manage the autonumber start number? Means
> autonumbering starts at 100 or 300000 instead of 0?
> Thanks for your help,
> HOA
>
|||Using identity columns in replication is supported and as other posters have
indicated this is covered in BOL. The exact use of identities in replication
depends on hte type of replication you have selected, but if for example you
were to do a merge publication, another tab appears on the article
properties which allows you to have SQL Server assign ranges to publisher
and subscriber which ensures there is no overlap in assigned numbers - this
is enforced by check constraints. You can alternatively manage the identity
ranges yourself and Michael Hotek shows how to do this on his site
(http://www.mssqlserver.com/replicati...h_identity.asp).
HTH,
Paul Ibison
I plan to crate a database and want to know if it's good to use autonumber
columns as my primary key or I should generate the numbers myself?
Also, If I want to replicate the DB, is it ok to use autonumber columns?
At last, Is there any way I can manage the autonumber start number? Means
autonumbering starts at 100 or 300000 instead of 0?
Thanks for your help,
HOA
Hoa wrote:
> Hi *.*
> I plan to crate a database and want to know if it's good to use autonumber
> columns as my primary key or I should generate the numbers myself?
> Also, If I want to replicate the DB, is it ok to use autonumber columns?
> At last, Is there any way I can manage the autonumber start number? Means
> autonumbering starts at 100 or 300000 instead of 0?
> Thanks for your help,
> HOA
>
I suggest you take a step back and spend a month researching all this
along with getting your database professionally designed. Every one of
those questions are so "depends" in nature that the very fact that you
asked them tells me you don't have a good enough grasp of the situation
to appreciate the answers.
But, quickly:
1) Depends.
2) Sorta. Depends.
3) Yes.
There is an entire section in the Books Online that is called
"Replication Data Considerations" with a topic "Using IDENTITY Values".
Have you not even bothered to read that section prior to posting your
very open ended question?
Zach
|||Identity columns are fine for PK... as long as you plan on keeping your identity values unique. PK values MUST be unique; Identity does not explicitly enforce uniqueness. Identity columns are good for PKs in the fact that they are INTEGER datatype. This d
atatype is small, so it works well w/ indexes (PK defaults to unique, clustered)
Identity columns may need to be set to 'NOT FOR REPLICATION' in certain situations. See Books Online: Replication topology & NOT FOR REPLICATION for more info.
Yes, you can start an Identity value at a number greater than 0 or 1... you declare it with the IDENTITY(10,5) clause (10 being the 'seed' value, 5 being the increment.
"Hoa" wrote:
> Hi *.*
> I plan to crate a database and want to know if it's good to use autonumber
> columns as my primary key or I should generate the numbers myself?
> Also, If I want to replicate the DB, is it ok to use autonumber columns?
> At last, Is there any way I can manage the autonumber start number? Means
> autonumbering starts at 100 or 300000 instead of 0?
> Thanks for your help,
> HOA
>
>
|||Oh boy. Books Online is your friend, don't let it be a stranger. These
issues are all covered in the documentation.
Your choice of a primary key depends on more factors than "it's good"... see
for a bit of my own opinion.
Using an IDENTITY in a replication scenario is okay, depending on what type
of replication. It will not work in merge replication, for example, since
IDENTITY can't guarantee uniqueness from two different database sources.
As for the identity, yes see the CREATE TABLE and DBCC CHECKIDENT tables in
Books Online. If the table hasn't been created:
CREATE TABLE Splunge
(sid INT IDENTITY(30000, 1))
INSERT Splunge DEFAULT VALUES
INSERT Splunge DEFAULT VALUES
SELECT * FROM Splunge
GO
DROP TABLE Splunge
Once again, please become familiar with Books Online. All of the questions
are answered, and then some, in the documentation you already have available
to you.
http://www.aspfaq.com/
(Reverse address to reply.)
"Hoa" <newpoorguy@.yahoo.com> wrote in message
news:eMTZ#DkeEHA.2804@.TK2MSFTNGP11.phx.gbl...
> Hi *.*
> I plan to crate a database and want to know if it's good to use
autonumber
> columns as my primary key or I should generate the numbers myself?
> Also, If I want to replicate the DB, is it ok to use autonumber columns?
> At last, Is there any way I can manage the autonumber start number? Means
> autonumbering starts at 100 or 300000 instead of 0?
> Thanks for your help,
> HOA
>
|||Using identity columns in replication is supported and as other posters have
indicated this is covered in BOL. The exact use of identities in replication
depends on hte type of replication you have selected, but if for example you
were to do a merge publication, another tab appears on the article
properties which allows you to have SQL Server assign ranges to publisher
and subscriber which ensures there is no overlap in assigned numbers - this
is enforced by check constraints. You can alternatively manage the identity
ranges yourself and Michael Hotek shows how to do this on his site
(http://www.mssqlserver.com/replicati...h_identity.asp).
HTH,
Paul Ibison
Autonumber an INT column
Hello,
I have a simple question. How do I autonumber an integer column called
agentID. I need to insert any rang of numbers in this column.Make it an Identity Column.. Just add the word Identity to the column
definition...
Create Table MyTable
(CustomerID Integer Identity Primary Key Not Null,
Name Varchar(35), etc...)
"Lontae Jones" wrote:
> Hello,
> I have a simple question. How do I autonumber an integer column called
> agentID. I need to insert any rang of numbers in this column.
I have a simple question. How do I autonumber an integer column called
agentID. I need to insert any rang of numbers in this column.Make it an Identity Column.. Just add the word Identity to the column
definition...
Create Table MyTable
(CustomerID Integer Identity Primary Key Not Null,
Name Varchar(35), etc...)
"Lontae Jones" wrote:
> Hello,
> I have a simple question. How do I autonumber an integer column called
> agentID. I need to insert any rang of numbers in this column.
Subscribe to:
Posts (Atom)