Showing posts with label totally. Show all posts
Showing posts with label totally. Show all posts

Tuesday, March 27, 2012

Cannot enter data into database

I'm a SQL newbie and am totally perplexed. I have tried to enter the
following data and I get the subsequent message.
INSERT INTO t_Answer ( AnswerID, AssessmentID, QuestionID, EvaluationValue,
AnswerText, CreationUser_ID, RevisionUser_ID )
VALUES ( 457 , 130, 4, '14', 'testing what I want to do better', 152, 152 )
Server: Msg 241, Level 16, State 1, Line 1
Syntax error converting datetime from character string.
As you can see, I'm not entering any datetime data. I do, however, have two
fields that are date time fields.
I don't know what to do next so that i can enter data in the database.
I've tried to enter info into another table and got the same message.
Thanks for your help,
KarolusHi
At http://www.aspfaq.com/etiquette.asp?id=5006 there is instructions to post
DDL which would tell us what datatypes your columns are.
Check if there are any triggers on this table or invalid defaults e.g.
CREATE TABLE MyDate ( ID INT, ADATE datetime NOT NULL DEFAULT 'Help' )
INSERT INTO MyDate (id) values (1)
gives your error.
John
"Karolus" wrote:

> I'm a SQL newbie and am totally perplexed. I have tried to enter the
> following data and I get the subsequent message.
> INSERT INTO t_Answer ( AnswerID, AssessmentID, QuestionID, EvaluationValue
,
> AnswerText, CreationUser_ID, RevisionUser_ID )
> VALUES ( 457 , 130, 4, '14', 'testing what I want to do better', 152, 152
)
> Server: Msg 241, Level 16, State 1, Line 1
> Syntax error converting datetime from character string.
> As you can see, I'm not entering any datetime data. I do, however, have t
wo
> fields that are date time fields.
> I don't know what to do next so that i can enter data in the database.
> I've tried to enter info into another table and got the same message.
> Thanks for your help,
> Karolus|||Thanks, John, I got the document. Here is the table definition. (Thanks fo
r
the advice.)
CREATE TABLE [t_Answer] (
[AnswerID] [CodeID] NOT NULL ,
[AssessmentID] [CodeID] NOT NULL ,
[QuestionID] [CodeID] NOT NULL ,
[EvaluationValue] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[AnswerText] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[RecordStatusID] [RecordStatusID] NOT NULL ,
[RecordID] [RecordID] IDENTITY (1, 1) NOT NULL ,
[CreationUser_ID] [KeyForeign] NOT NULL ,
[CreationDtm] [DateTmCreated] NOT NULL ,
[RevisionUser_ID] [KeyForeign] NOT NULL ,
[RevisionDtm] [DateTimeRequired] NOT NULL ,
CONSTRAINT [COMMENTID] PRIMARY KEY CLUSTERED
(
[AnswerID],
[AssessmentID],
[QuestionID]
) ON [PRIMARY] ,
CONSTRAINT [fk_Answer_AssessmentID_Assessment] FOREIGN KEY
(
[AssessmentID]
) REFERENCES [t_Assessment] (
[AssessmentID]
),
CONSTRAINT [fk_Answer_QuestionID_QuestionID] FOREIGN KEY
(
[QuestionID]
) REFERENCES [t_QuestionID] (
[QuestionID]
)
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
I hope this information is helpful. I don't understand what I'm screwing up
.
"John Bell" wrote:
> Hi
> At http://www.aspfaq.com/etiquette.asp?id=5006 there is instructions to po
st
> DDL which would tell us what datatypes your columns are.
> Check if there are any triggers on this table or invalid defaults e.g.
> CREATE TABLE MyDate ( ID INT, ADATE datetime NOT NULL DEFAULT 'Help' )
> INSERT INTO MyDate (id) values (1)
> gives your error.
> John
> "Karolus" wrote:
>|||Please supply the definitions of the user-defined types: CodeID,
RecordStatusID, RecordID, KeyForeign, DateTmCreated, and DateTimeRequired.
I suspect the problem is to be found there, or in a default attached to a
user defined type.
"Karolus" <Karolus@.discussions.microsoft.com> wrote in message
news:B32CFD3E-BF21-471D-8E32-F33B5E616DE1@.microsoft.com...
> Thanks, John, I got the document. Here is the table definition. (Thanks
for
> the advice.)
> CREATE TABLE [t_Answer] (
> [AnswerID] [CodeID] NOT NULL ,
> [AssessmentID] [CodeID] NOT NULL ,
> [QuestionID] [CodeID] NOT NULL ,
> [EvaluationValue] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [AnswerText] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [RecordStatusID] [RecordStatusID] NOT NULL ,
> [RecordID] [RecordID] IDENTITY (1, 1) NOT NULL ,
> [CreationUser_ID] [KeyForeign] NOT NULL ,
> [CreationDtm] [DateTmCreated] NOT NULL ,
> [RevisionUser_ID] [KeyForeign] NOT NULL ,
> [RevisionDtm] [DateTimeRequired] NOT NULL ,
> CONSTRAINT [COMMENTID] PRIMARY KEY CLUSTERED
> (
> [AnswerID],
> [AssessmentID],
> [QuestionID]
> ) ON [PRIMARY] ,
> CONSTRAINT [fk_Answer_AssessmentID_Assessment] FOREIGN KEY
> (
> [AssessmentID]
> ) REFERENCES [t_Assessment] (
> [AssessmentID]
> ),
> CONSTRAINT [fk_Answer_QuestionID_QuestionID] FOREIGN KEY
> (
> [QuestionID]
> ) REFERENCES [t_QuestionID] (
> [QuestionID]
> )
> ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
> GO
>
> I hope this information is helpful. I don't understand what I'm screwing
up.
> "John Bell" wrote:
>
post
EvaluationValue,
152 )
have two|||Hi Karolus,
I agree with John. You may need to check triggers entering values into
RevisionDtm and CreationDtm.
You have four not null fields for that you didn't provide values in
your insert statement,
so you may have triggers for them.
I hope it help you.
Kim|||Hi
CreationDtm and Revisiondtm are not nullable, but you have not supplied a
value in your statement, therefore you would get an error for that but
normally not the one you have stated, therefore I think you may have default
s
in the user defined types DateTimeRequired and DateTmCreated that are
incorrect.
John
"Karolus" wrote:
> Thanks, John, I got the document. Here is the table definition. (Thanks
for
> the advice.)
> CREATE TABLE [t_Answer] (
> [AnswerID] [CodeID] NOT NULL ,
> [AssessmentID] [CodeID] NOT NULL ,
> [QuestionID] [CodeID] NOT NULL ,
> [EvaluationValue] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [AnswerText] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
> [RecordStatusID] [RecordStatusID] NOT NULL ,
> [RecordID] [RecordID] IDENTITY (1, 1) NOT NULL ,
> [CreationUser_ID] [KeyForeign] NOT NULL ,
> [CreationDtm] [DateTmCreated] NOT NULL ,
> [RevisionUser_ID] [KeyForeign] NOT NULL ,
> [RevisionDtm] [DateTimeRequired] NOT NULL ,
> CONSTRAINT [COMMENTID] PRIMARY KEY CLUSTERED
> (
> [AnswerID],
> [AssessmentID],
> [QuestionID]
> ) ON [PRIMARY] ,
> CONSTRAINT [fk_Answer_AssessmentID_Assessment] FOREIGN KEY
> (
> [AssessmentID]
> ) REFERENCES [t_Assessment] (
> [AssessmentID]
> ),
> CONSTRAINT [fk_Answer_QuestionID_QuestionID] FOREIGN KEY
> (
> [QuestionID]
> ) REFERENCES [t_QuestionID] (
> [QuestionID]
> )
> ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
> GO
>
> I hope this information is helpful. I don't understand what I'm screwing
up.
> "John Bell" wrote:
>|||Thanks all for your help. I VERY much appreciate it. I've come for Sybase
and am overwhelmed by the difference. Here are the domain definitions and
the code that created the table, t_answers. I assumed that I should provide
a datetime, but that didn't work either...so I'm .
Here's the information:
/ *=======================================
=======================*/
/* Domain: DateTmCreated */
/ *=======================================
=======================*/
sp_addtype DateTmCreated, 'datetime' , 'not null'
go
/ *=======================================
=======================*/
/* Domain: DateTimeNotMandatory */
/ *=======================================
=======================*/
sp_addtype DateTimeNotMandatory, 'datetime'
go
/ *=======================================
=======================*/
/* Domain: DateTimeRequired */
/ *=======================================
=======================*/
sp_addtype DateTimeRequired, 'datetime' , 'not null'
go
create default D_DateTimeRequired
as 'CURRENT TIMESTAMP'
go
sp_bindefault D_DateTimeRequired, DateTimeRequired
go
/ *=======================================
=======================*/
/* Domain: DateTm */
/ *=======================================
=======================*/
sp_addtype DateTm, 'datetime'
go
create default D_DateTm
as 'CURRENT TIMESTAMP'
go
sp_bindefault D_DateTm, DateTm
go
/ *=======================================
=======================*/
/* Table : t_Answer */
/ *=======================================
=======================*/
create table t_Answer (
AnswerID CodeID not null,
AssessmentID CodeID not null,
QuestionID CodeID not null,
EvaluationValue text null,
AnswerText text null,
RecordStatusID RecordStatusID not null,
RecordID RecordID identity,
CreationUser_ID KeyForeign not null,
CreationDtm DateTmCreated not null,
RevisionUser_ID KeyForeign not null,
RevisionDtm DateTimeRequired not null,
constraint COMMENTID primary key (AnswerID, AssessmentID, QuestionID)
)
go
"John Bell" wrote:
> Hi
> CreationDtm and Revisiondtm are not nullable, but you have not supplied a
> value in your statement, therefore you would get an error for that but
> normally not the one you have stated, therefore I think you may have defau
lts
> in the user defined types DateTimeRequired and DateTmCreated that are
> incorrect.
> John
> "Karolus" wrote:
>|||Looks like the error is just the CREATE DEFAULT statements.
CURRENT_TIMESTAMP is a keyword and mustn't be quoted as a string:
CREATE DEFAULT D_DateTm
AS CURRENT_TIMESTAMP
David Portas
SQL Server MVP
--sql

Sunday, February 19, 2012

Cannot Connect to SQL Server 2000 Using Domain Account

Hi folks:
I'm new here so please bear with me. I have a problem that is totally
driving me crazy, and it seems like it should be simple but for the life of
me I can't figure it out.
My question is simple: How do I connect to a Microsoft SQL 2000 server using
a domain account? Let me run through what I've done and what I'm trying to do.
I go to Enterprise Manager, expand my server, and click on
SECURITY...LOGINS. I create a new Login. I want to use Windows
Authentication, so I select that. Selecting that prompts me to select my
domain name, which I do. Let's suppose that the domain is named MCD. OK,
now I type in the name of the account, WHICH MATCHES THE DOMAIN ACCOUNT
IDENTICALLY! So, for example, I type in TestAccount, which combined with the
domain name is now MCD\TestAccount. I grant the account access to the
database and make it a full system administrator. I click OK, and the
account looks great.
HOWEVER, when I try to login using Query Analyzer or OSQL, I get "Login
failed for user MCD\TestAccount." Why?! I must just be missing something, but
I have no idea what it could be. I can authenticate to other resources using
that account just fine. For example, I created a network share on another
server and granted just that test account permissions to it. I can connect
to it using that domain account with no problem, so I know the domain account
is OK.
Any ideas?Are you logged into the client machine using that TestAccount, SqlServer
will pass on the credential of the logged in user.
if you are logged in as MCD\NormK and trying to connect to the sql server
using MCD\TestAccount that is not possible, (at least not from query
analyzer), You can connect to Network Share using different account.
(different username )
HTH
--
Rakesh Ajwani
MCSD, MCSD.NET
"NormK" wrote:
> Hi folks:
> I'm new here so please bear with me. I have a problem that is totally
> driving me crazy, and it seems like it should be simple but for the life of
> me I can't figure it out.
> My question is simple: How do I connect to a Microsoft SQL 2000 server using
> a domain account? Let me run through what I've done and what I'm trying to do.
> I go to Enterprise Manager, expand my server, and click on
> SECURITY...LOGINS. I create a new Login. I want to use Windows
> Authentication, so I select that. Selecting that prompts me to select my
> domain name, which I do. Let's suppose that the domain is named MCD. OK,
> now I type in the name of the account, WHICH MATCHES THE DOMAIN ACCOUNT
> IDENTICALLY! So, for example, I type in TestAccount, which combined with the
> domain name is now MCD\TestAccount. I grant the account access to the
> database and make it a full system administrator. I click OK, and the
> account looks great.
> HOWEVER, when I try to login using Query Analyzer or OSQL, I get "Login
> failed for user MCD\TestAccount." Why?! I must just be missing something, but
> I have no idea what it could be. I can authenticate to other resources using
> that account just fine. For example, I created a network share on another
> server and granted just that test account permissions to it. I can connect
> to it using that domain account with no problem, so I know the domain account
> is OK.
> Any ideas?