Tuesday, March 20, 2012
Primary key allows null?
I have a table that I have assigned multiple fields as the primary key(s).
There are about 6 fields that make up the primary key for this table. When
entering a new record into the table the primary key forces me to enter all
the data fields for the primary key. BUT.. if I were to copy a record and
remove the data from one of the PK fields, SQL Server accepts this. How is
this possible? I have this field designated as PK and it cannot accept a
null, but it does. Any help on this would be much appreciated.Mark wrote:
> XP Pro / Access 2003 Project / SQL Server 2000 Backend
> I have a table that I have assigned multiple fields as the primary key(s).
> There are about 6 fields that make up the primary key for this table. Whe
n
> entering a new record into the table the primary key forces me to enter al
l
> the data fields for the primary key. BUT.. if I were to copy a record an
d
> remove the data from one of the PK fields, SQL Server accepts this. How i
s
> this possible? I have this field designated as PK and it cannot accept a
> null, but it does. Any help on this would be much appreciated.
Depends what you mean by "remove all the data". If it's a string then
it can be empty. An empty string isn't null. If it's a numeric then it
can be zero. Did you run a query to check what the value *really* is in
the table rather than just look at what you are shown in a grid
control?
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
--|||> this possible? I have this field designated as PK and it cannot accept a
> null, but it does. Any help on this would be much appreciated.
Are you sure? Are you certain that a unique constraint is not being used as
a PK (which will allow nulls)? Below is a simple proof.
set nocount on
-- this will fail
create table #test (id1 int not null, id2 int null, other_junk varchar(20)
not null,
constraint pkx primary key (id1, id2) )
go
-- this will succeed
create table #test (id1 int not null, id2 int null, other_junk varchar(20)
not null,
constraint pkx unique (id1, id2) )
go
-- 1 of 2 will succeed
insert #test (id1, id2, other_junk) values (1, 1, 'test')
insert #test (id1, id2, other_junk) values (1, 1, 'test')
go
-- all will succeed
insert #test (id1, id2, other_junk) values (1, 2, 'test')
insert #test (id1, id2, other_junk) values (2, 1, 'test')
insert #test (id1, id2, other_junk) values (1, null, 'test')
go
-- this will fail
insert #test (id1, id2, other_junk) values (1, null, 'test')
go
-- this will succeed
update #test set id2 = null where id1 = 2 and id2 = 1
go
-- final result
select * from #test
go
drop table #test
go
Primary key allows null?
I have a table that I have assigned multiple fields as the primary key(s).
There are about 6 fields that make up the primary key for this table. When
entering a new record into the table the primary key forces me to enter all
the data fields for the primary key. BUT.. if I were to copy a record and
remove the data from one of the PK fields, SQL Server accepts this. How is
this possible? I have this field designated as PK and it cannot accept a
null, but it does. Any help on this would be much appreciated.Mark wrote:
> XP Pro / Access 2003 Project / SQL Server 2000 Backend
> I have a table that I have assigned multiple fields as the primary key(s).
> There are about 6 fields that make up the primary key for this table. When
> entering a new record into the table the primary key forces me to enter all
> the data fields for the primary key. BUT.. if I were to copy a record and
> remove the data from one of the PK fields, SQL Server accepts this. How is
> this possible? I have this field designated as PK and it cannot accept a
> null, but it does. Any help on this would be much appreciated.
Depends what you mean by "remove all the data". If it's a string then
it can be empty. An empty string isn't null. If it's a numeric then it
can be zero. Did you run a query to check what the value *really* is in
the table rather than just look at what you are shown in a grid
control?
--
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
--|||> this possible? I have this field designated as PK and it cannot accept a
> null, but it does. Any help on this would be much appreciated.
Are you sure? Are you certain that a unique constraint is not being used as
a PK (which will allow nulls)? Below is a simple proof.
set nocount on
-- this will fail
create table #test (id1 int not null, id2 int null, other_junk varchar(20)
not null,
constraint pkx primary key (id1, id2) )
go
-- this will succeed
create table #test (id1 int not null, id2 int null, other_junk varchar(20)
not null,
constraint pkx unique (id1, id2) )
go
-- 1 of 2 will succeed
insert #test (id1, id2, other_junk) values (1, 1, 'test')
insert #test (id1, id2, other_junk) values (1, 1, 'test')
go
-- all will succeed
insert #test (id1, id2, other_junk) values (1, 2, 'test')
insert #test (id1, id2, other_junk) values (2, 1, 'test')
insert #test (id1, id2, other_junk) values (1, null, 'test')
go
-- this will fail
insert #test (id1, id2, other_junk) values (1, null, 'test')
go
-- this will succeed
update #test set id2 = null where id1 = 2 and id2 = 1
go
-- final result
select * from #test
go
drop table #test
go
Saturday, February 25, 2012
Preview error
I'm trying to use Reporting Services, I have installed the client component on my computer (Win 2K pro sp4) and I try to start to design a new report. The data source is a SQL Server developer edition Sp3 installed on the same computer.
All works fine until I try to preview the report using the preview tab from the designer. I received this message "command 'view.output' not available.
My Visual Studio version is EA enghlish version. I have installed the RS SP1 with the same results.
Anyone can help me ?
Thank's in advance and I apologize for my poor englishDo you have any add-ins installed? Can you select View\Other Windows\Output
from the View menu? What happens if you open the VS Command Window, and type
"View.Output" ?
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote in
message news:79F377AF-8255-473C-9AFE-6833731E7E65@.microsoft.com...
> Hi,
> I'm trying to use Reporting Services, I have installed the client
> component on my computer (Win 2K pro sp4) and I try to start to design a
> new report. The data source is a SQL Server developer edition Sp3
> installed on the same computer.
> All works fine until I try to preview the report using the preview tab
> from the designer. I received this message "command 'view.output' not
> available.
> My Visual Studio version is EA enghlish version. I have installed the RS
> SP1 with the same results.
> Anyone can help me ?
> Thank's in advance and I apologize for my poor english|||What do you mean for add-ins ?
Yes I can select View\Other Windows\Output from the View menu.
If I open the VS Command Windows and type View.Output is not recognized as command.
"Lev Semenets [MSFT]" wrote:
> Do you have any add-ins installed? Can you select View\Other Windows\Output
> from the View menu? What happens if you open the VS Command Window, and type
> "View.Output" ?
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote in
> message news:79F377AF-8255-473C-9AFE-6833731E7E65@.microsoft.com...
> > Hi,
> > I'm trying to use Reporting Services, I have installed the client
> > component on my computer (Win 2K pro sp4) and I try to start to design a
> > new report. The data source is a SQL Server developer edition Sp3
> > installed on the same computer.
> > All works fine until I try to preview the report using the preview tab
> > from the designer. I received this message "command 'view.output' not
> > available.
> > My Visual Studio version is EA enghlish version. I have installed the RS
> > SP1 with the same results.
> > Anyone can help me ?
> > Thank's in advance and I apologize for my poor english
>
>|||Please type ">View.Output"
Leading ">" is required there.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote in
message news:267039CE-E33E-42BB-8B69-E20E23F55AC0@.microsoft.com...
> What do you mean for add-ins ?
> Yes I can select View\Other Windows\Output from the View menu.
> If I open the VS Command Windows and type View.Output is not recognized as
> command.
>
> "Lev Semenets [MSFT]" wrote:
>> Do you have any add-ins installed? Can you select View\Other
>> Windows\Output
>> from the View menu? What happens if you open the VS Command Window, and
>> type
>> "View.Output" ?
>> --
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote
>> in
>> message news:79F377AF-8255-473C-9AFE-6833731E7E65@.microsoft.com...
>> > Hi,
>> > I'm trying to use Reporting Services, I have installed the client
>> > component on my computer (Win 2K pro sp4) and I try to start to design
>> > a
>> > new report. The data source is a SQL Server developer edition Sp3
>> > installed on the same computer.
>> > All works fine until I try to preview the report using the preview tab
>> > from the designer. I received this message "command 'view.output' not
>> > available.
>> > My Visual Studio version is EA enghlish version. I have installed the
>> > RS
>> > SP1 with the same results.
>> > Anyone can help me ?
>> > Thank's in advance and I apologize for my poor english
>>|||I haven't understand while window you mean, I confused it with the VS Command Prompt.
So if I try to type > View. I can see in the intellisense window the Output method but when I select it i obtain this message "Comando "View.Output" non disponibile" translate in enghlish "Comand "View.Output" not available".
Do you think that the problem may be that I use VS EA in eghlish on a Windows 2000 Pro Italian machine ?
Many thanks for your help
"Lev Semenets [MSFT]" wrote:
> Please type ">View.Output"
> Leading ">" is required there.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote in
> message news:267039CE-E33E-42BB-8B69-E20E23F55AC0@.microsoft.com...
> > What do you mean for add-ins ?
> > Yes I can select View\Other Windows\Output from the View menu.
> > If I open the VS Command Windows and type View.Output is not recognized as
> > command.
> >
> >
> > "Lev Semenets [MSFT]" wrote:
> >
> >> Do you have any add-ins installed? Can you select View\Other
> >> Windows\Output
> >> from the View menu? What happens if you open the VS Command Window, and
> >> type
> >> "View.Output" ?
> >>
> >> --
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.
> >>
> >>
> >> "Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote
> >> in
> >> message news:79F377AF-8255-473C-9AFE-6833731E7E65@.microsoft.com...
> >> > Hi,
> >> > I'm trying to use Reporting Services, I have installed the client
> >> > component on my computer (Win 2K pro sp4) and I try to start to design
> >> > a
> >> > new report. The data source is a SQL Server developer edition Sp3
> >> > installed on the same computer.
> >> > All works fine until I try to preview the report using the preview tab
> >> > from the designer. I received this message "command 'view.output' not
> >> > available.
> >> > My Visual Studio version is EA enghlish version. I have installed the
> >> > RS
> >> > SP1 with the same results.
> >> > Anyone can help me ?
> >> > Thank's in advance and I apologize for my poor english
> >>
> >>
> >>
>
>|||This is some weird VS problem...
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote in
message news:18EA1D58-65E7-4117-8FCC-F078862D0F08@.microsoft.com...
>I haven't understand while window you mean, I confused it with the VS
>Command Prompt.
> So if I try to type > View. I can see in the intellisense window the
> Output method but when I select it i obtain this message "Comando
> "View.Output" non disponibile" translate in enghlish "Comand "View.Output"
> not available".
> Do you think that the problem may be that I use VS EA in eghlish on a
> Windows 2000 Pro Italian machine ?
> Many thanks for your help
> "Lev Semenets [MSFT]" wrote:
>> Please type ">View.Output"
>> Leading ">" is required there.
>> --
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com> wrote
>> in
>> message news:267039CE-E33E-42BB-8B69-E20E23F55AC0@.microsoft.com...
>> > What do you mean for add-ins ?
>> > Yes I can select View\Other Windows\Output from the View menu.
>> > If I open the VS Command Windows and type View.Output is not recognized
>> > as
>> > command.
>> >
>> >
>> > "Lev Semenets [MSFT]" wrote:
>> >
>> >> Do you have any add-ins installed? Can you select View\Other
>> >> Windows\Output
>> >> from the View menu? What happens if you open the VS Command Window,
>> >> and
>> >> type
>> >> "View.Output" ?
>> >>
>> >> --
>> >> This posting is provided "AS IS" with no warranties, and confers no
>> >> rights.
>> >>
>> >>
>> >> "Roberto Pasqualini" <RobertoPasqualini@.discussions.microsoft.com>
>> >> wrote
>> >> in
>> >> message news:79F377AF-8255-473C-9AFE-6833731E7E65@.microsoft.com...
>> >> > Hi,
>> >> > I'm trying to use Reporting Services, I have installed the client
>> >> > component on my computer (Win 2K pro sp4) and I try to start to
>> >> > design
>> >> > a
>> >> > new report. The data source is a SQL Server developer edition Sp3
>> >> > installed on the same computer.
>> >> > All works fine until I try to preview the report using the preview
>> >> > tab
>> >> > from the designer. I received this message "command 'view.output'
>> >> > not
>> >> > available.
>> >> > My Visual Studio version is EA enghlish version. I have installed
>> >> > the
>> >> > RS
>> >> > SP1 with the same results.
>> >> > Anyone can help me ?
>> >> > Thank's in advance and I apologize for my poor english
>> >>
>> >>
>> >>
>>
preview data, it gives you incorrect results
Using VS05 SP1 Pro SQL Express…
Take a simple stored procedure like the following to return a specific column from a specific row in a data table ....
SELECT fld_IX_UserID
FROM UserIDs
WHERE (fld_UserID_Table_ID = @.USERID_TABLE_ID)
It works fine in Store Procedure, and if you create at table adapter to reference it, that works fine as well.
Here is the issue. In the store procedure (i.e. under Server Explorer), when you execute the command to test it, it gives you the correct results. In Edit with Dataset Designer, Table Adapater, if you highlight it, right click preview data, it gives you incorrect results. In code, the table adapter gives you the correct resutls.
In every case, Preview Results for a table adapter built on a stored procedure will give you the wrong results. This is clearly a bug and can result in a log of wasted time.
Am I missing something? FYI, I realize I don't need to use the Table Adapater to execute the above stored procedure, but we are using table adapters for everything to be consistent.
Thanks,
Bob
i am not good in .net ... so i cannot comment on that.. but if you are getting different result while u run the same SP means the input parameter which you pass is differ for each run. check what is the value set for @.USERID_TABLE_ID in each run
Madhu
|||No the stored procedure returnes the correct data every time.
It is the Preview Data, in the IDE table adapter designer view, that returns incorrect data everytime, but only for Store Procedures used as table adapters.
Bob
|||Hi Bob,
I would suggest you post this bug to http://connect.microsoft.com. You should be able to find the VS Connection and enter the issue there. That will put the issue into their tracking system. Since bad data is happening only through VS, it should be filed with VS.
Mike
Monday, February 20, 2012
prevent users from modifying tables or data but allow creating and modifying store pro
Is there a way in Sql Server to prevent a user from modifying tables or data
but allow creating and modifying store procedures?
thanks!!Hmmm, that would be a strange one. I guess you would want them to be able
to create a procedure, but they wouldn't be able to execute it (even if only
to test it), because they could easily put ALTER TABLE or UPDATE in there?
You can prevent writing of data by:
USE <database>
GO
EXEC sp_addrolemember 'db_denydatawriter', '<user name>'
GO
As for allowing CREATE PROCEDURE but not ALTER TABLE, hmm, not sure about
that one. With SQL Server 2005, you could roll back unauthorized table mods
using DDL triggers...
http://www.aspfaq.com/
(Reverse address to reply.)
"Zeng" <zzy@.nonospam.com> wrote in message
news:uKtrn3tjEHA.1644@.tk2msftngp13.phx.gbl...
> Hello
> Is there a way in Sql Server to prevent a user from modifying tables or
data
> but allow creating and modifying store procedures?
> thanks!!
>|||right click database, properties, permissions tab.
there are check boxes you can use to deny users to create table but allow
them to create sp.
steve
"Zeng" <zzy@.nonospam.com> wrote in message
news:uKtrn3tjEHA.1644@.tk2msftngp13.phx.gbl...
> Hello
> Is there a way in Sql Server to prevent a user from modifying tables or
data
> but allow creating and modifying store procedures?
> thanks!!
>