ISQL: Msg 170, Level 15, State 1, Line 1 Line 1: Incorrect Syntax Near ' '

Nov 8, 2006

G'day everyone

That's a space between the ticks.

It's all part of a longer script but seeing as the failure occurs on
line 1

if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[config]') and OBJECTPROPERTY(id, N'IsUserTable') =
1)
drop table [dbo].[config]
GO

That's three lines only. Does it matter that they're in Unicode?

Any ideas?

Kind regards,
Bruce M. Axtens
Software Engineer
Strapper Technologies

View 3 Replies


ADVERTISEMENT

Msg 156, Level 15, State 1, Line 19,Incorrect Syntax Near The Keyword 'IDENTITY'.

Feb 29, 2008

Here is a Database script I wrote: I can't figure out what the problem is when I declare my primary Keys in the second and third table.
Thanks in Advance

Errors:

Msg 156, Level 15, State 1, Line 19

Incorrect syntax near the keyword 'IDENTITY'.

Msg 156, Level 15, State 1, Line 29

Incorrect syntax near the keyword 'IDENTITY'.



CREATE DATABASE GoGreen

Go


USE GoGreen

Create TABLE Student

(StudentID INT NOT NULL IDENTITY PRIMARY KEY, <---no Error here

DrivePassCode char(3) NOT NULL,

LName varchar(50) NOT NULL,

FName varchar(50) NOT NULL,

Address1 varchar(50) NOT NULL,

Address2 varchar(50) NULL,

City varchar(50) NOT NULL,

PostalCode varchar(20) NOT NULL,

PhoneNumber varchar(50) NOT NULL,

Email varchar(50) NOT NULL,

Smoker char(2) NOT NULL,

NearestCityOrTown varchar(50) NOT NULL,

PaymentType varchar(20) NOT NULL,)


CREATE TABLE CoordinatedRideShare

(RideID INT NOT NULL, IDENTITY PRIMARY KEY, <---Error #1

StudentID INT NOT NULL REFERENCES Student(StudentID)

[ON DELETE {CASCADE}]

[ON UPDATE {CASCADE}],

M-W ARRIVAL TIME smalldatetime NOT NULL,

M-W DEPART TIME smalldatetime NOT NULL,

T-TH ARRIVAL TIME smalldatetime NOT NULL,

T-TH DEPART TIME smalldatetime NOT NULL,)


CREATE TABLE MeetingLocation

(LocationID INT NOT NULL, IDENTITY PRIMARY KEY AUTONUMBER, <---Error#2

RideID INT NOT NULL REFERENCES Coordinated RideShare(RideID)

[ON DELETE {CASCADE}]

[ON UPDATE {CASCADE}],

House Pickup char(1) NULL,

General meeting place varchar(50) NULL,)


CREATE INDEX DrivePass

ON Student (DrivePass)

CREATE INDEX NearestCityOrTown

ON Sudent (NearestCityOrTown)

View 9 Replies View Related

Line 1: Incorrect Syntax Near '-'. But There Is No '-' In First Line!

Dec 28, 2007

  HiIt's my stored procedure 1 CREATE PROCEDURE singleSearch2
2 @SQ nvarchar(30),
3 @pType nvarchar(11),
4 @pCol nvarchar(11)
5 AS
6 BEGIN
7 DECLARE @SQL NVarChar(1000)
8 SELECT @SQL='SELECT *,'
9 SELECT @SQL=@SQL+' CASE RTRIM(LTRIM(op))'
10 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e'+CHAR(39)+' THEN '+CHAR(39)+'اجاره'+ CHAR(39)
11 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'r'+CHAR(39)+' THEN '+CHAR(39)+'رهن'+CHAR(39)
12 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'f'+ CHAR(39)+' THEN '+ CHAR(39) +' Ù?روش '+CHAR(39)
13 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e r'+CHAR(39)+' THEN '+CHAR(39)+ 'اجاره - رهن '+CHAR(39)
14 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e f'+CHAR(39)+' THEN '+CHAR(39)+'اجاره - Ù?روش '+CHAR(39)
15 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'r f'+CHAR(39)+' THEN '+CHAR(39)+' رهن - Ù?روش '+CHAR(39)
16 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'e r f'+CHAR(39)+' THEN '+CHAR(39)+'اجاره - رهن - Ù?روش'+CHAR(39)
17 SELECT @SQL=@SQL+' ELSE op END AS xop, CASE LTRIM(RTRIM(type)) '
18 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'z -'+CHAR(39)+' THEN '+CHAR(39)+'زمین'+CHAR(39)
19 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'m -'+CHAR(39)+' THEN '+CHAR(39)+'مسکونی'+CHAR(39)
20 SELECT @SQL=@SQL+' WHEN '+CHAR(39)+'t -'+CHAR(39)+' THEN '+CHAR(39)+'تجاری'+CHAR(39)
21 SELECT @SQL=@SQL+' ELSE [type] END AS [xtype] FROM [data] '
22 SELECT @SQL=@SQL+' WHERE ([type] LIKE %'+CHAR(39)+@pType+CHAR(39)+'%) AND ('+@pCol+' LIKE %'+CHAR(39)+@SQ+CHAR(39)+'%)'
23 Exec (@SQL)
24 END
25 GO
 and i face this error: Line 1: Incorrect syntax near '-'.

View 3 Replies View Related

Msg 107, Level 16, State 2, Line 1

Feb 1, 2006

Hi,I am getting the following error from the query below against SQLServer 8.00.2039 (SP4)Error:====Server: Msg 107, Level 16, State 2, Line 1The column prefix 'd' does not match with a table name or alias nameused in the query.Select Statement:=============select ....from trades a,gems_product_groups b,portfolio_nav_mapping c,products d,limit_types eleft outer join gems_prod_trade_mod f on d.product_id =f.product_IDI know this was a known bug in MS-SQL7, but I thought it had been fixedin 2000.Can anyone help?Thanks

View 3 Replies View Related

Server: Msg 209, Level 16, State 1, Line 6 HELP

Jun 7, 2005

Simple SQL Error Can anyone help for a new starter. Error MessageServer: Msg 209, Level 16, State 1, Line 6 Ambiguous column name 'CustomerID'.Codeselect CustomerID, ContactName, OrderId from CustomersInner Join Orders OnCustomers.CustomerID = Orders.CustomerIDDBMS = SQL Server 2000 SP 3aDatabase = NorthwindI have no idea why i receive this error

View 1 Replies View Related

Server: Msg 536, Level 16, State 3, Line 1

Mar 16, 2001

Hi, I would appreciate your help. I donot know why I am getting this error when I run this query :
if (select SUBSTRING(de_ftpdownload,1,CHARINDEX('.',de_ftpdow nload,0)-1)as de_ftpdownload from vendor_invoice)
<> (select stamp_number from vendor_invoice)
select 'no'
else
select 'yes'

I get this Error
Server: Msg 536, Level 16, State 3, Line 1
Invalid length parameter passed to the substring function.
----
yes
(1 row(s) affected)
I would appreciate your hlep

Al

View 1 Replies View Related

Server: Msg 107, Level 16, State 2, Line 1

Jun 23, 2004

Can anybody help me with this syntax?
select
PHN.N_PHN_ID 'ID',
PHN.N_PHN_AREACD 'AREAD1',
PHN.N_PHN_PREFIX 'PREFIXD1',
PHN.N_PHN_NUMBER 'NBRD1',
PHN.N_PHN_EXTENTN 'EXTD1',
PHN2.N_PHN_AREACD 'AREAD2',
PHN2.N_PHN_PREFIX 'PREFIXD2',
PHN2.N_PHN_NUMBER 'NBRD2',
PHN2.N_PHN_EXTENTN 'EXTD2'
from Donor_Visit2 DV2 RIGHT OUTER JOIN NAT_PHN_DB_REC PHN
ON DV2.COUNT_INSTID = PHN.N_PHN_INSTID
RIGHT OUTER JOIN NAT_PHN_DB_REC PHN2
ON DV2.COUNT_ID = PHN2.PHN.N_PHN_ID
order by PHN.N_PHN_ID

here is the error message:
Server: Msg 107, Level 16, State 2, Line 1
The column prefix 'PHN2.PHN' does not match with a table name or alias name used in the query.

View 1 Replies View Related

Server: Msg 208, Level 16, State 1, Line 1

Nov 22, 2004

Hello All,

This table was created by coldfusion and has been given all priviliges to public and I am in the public group but I still cant select from it. It gives me this error message: Server: Msg 208, Level 16, State 1, Line 1. Help!

Thanks in Advance.

View 5 Replies View Related

Msg 8101, Level 16, State 1, Line 68

Feb 15, 2008

I'm getting this error in SQL server.
Msg 8101, Level 16, State 1, Line 68
An explicit value for the identity column in table 'temp_notes' can only be specified when a column list is used and IDENTITY_INSERT is ON.

My original script looked like this.

SET NOCOUNT ON

DECLARE @patient_id int
,@phn varchar(9)
,@full_name varchar(100)
,@birth_date datetime
,@entry_note varchar(8000)
,@entry_date datetime
,@rec_counter int
,@Clinic_identifier varchar(24)
,@chart_count int

set @Clinic_identifier = 'MEDOWL.'
set @rec_counter = 0


DECLARE patients_cursor CURSOR FOR
SELECT a.full_name, a.birth_date, a.phn, a.patient_id
FROM patient as a
,clinicdoctors as b
WHERE a.patient_id IN (51450,49741,57290) --= 51450
and datalength(a.phn) = 9
and b.clinicdoctor_id = a.clinicdoctor_id
ORDER BY a.last_name,a.first_name,a.patient_id

OPEN patients_cursor
FETCH NEXT FROM patients_cursor
INTO @full_name, @birth_date, @phn, @patient_id

--select @full_name, @birth_date, @phn, @patient_id


WHILE @@FETCH_STATUS = 0

BEGIN

DECLARE chartcount_cursor CURSOR FOR
select count(*)
from ChartEntries
where patient_id = @patient_id


OPEN chartcount_cursor
FETCH NEXT FROM chartcount_cursor INTO @chart_count

--select @chart_count as chtcount

DECLARE chartentries_cursor CURSOR FOR
select entry_datetime,entry_note
from ChartEntries
where patient_id = @patient_id
order by Patient_id, ChartEntry_Id desc

-- Variable value from the outer cursor

OPEN chartentries_cursor
FETCH NEXT FROM chartentries_cursor INTO @entry_date,@entry_note
--select @entry_date,@entry_note

WHILE @@FETCH_STATUS = 0

BEGIN
set @rec_counter = @rec_counter + 1
--select @@FETCH_STATUS as status
IF @@FETCH_STATUS = 0

insert into temp_notes
values (@Clinic_identifier+@phn+'.'
+convert(varchar,@rec_counter)+'.'
+convert(varchar,@chart_count),
@phn,
@full_name,
@birth_date,
@entry_date,
@entry_note
)

-- Get the next entry note
FETCH NEXT FROM chartentries_cursor INTO @entry_date,@entry_note
--select @entry_date,@entry_note

END
CLOSE chartentries_cursor
DEALLOCATE chartentries_cursor
CLOSE chartcount_cursor
DEALLOCATE chartcount_cursor


set @rec_counter = 0
set @chart_count = 0

-- Get the next patient record
FETCH NEXT FROM patients_cursor
INTO @full_name, @birth_date, @phn, @patient_id

--select @full_name, @birth_date, @phn, @patient_id

-- Get the next chart record count
--FETCH NEXT FROM chartcount_cursor INTO @chart_count
--select @chart_count as chtcount

END

CLOSE patients_cursor
DEALLOCATE patients_cursor

GO

I then changed it to left pad the variables @rec_counter and @chart_count.
SET NOCOUNT ON

DECLARE @patient_id int
,@phn varchar(9)
,@full_name varchar(100)
,@birth_date datetime
,@entry_note varchar(8000)
,@entry_date datetime
,@rec_counter int
,@Clinic_identifier varchar(24)
,@chart_count int

set @Clinic_identifier = 'MEDOWL.'
set @rec_counter = 0


DECLARE patients_cursor CURSOR FOR
SELECT a.full_name, a.birth_date, a.phn, a.patient_id
FROM patient as a
,clinicdoctors as b
WHERE a.patient_id IN (51450,49741,57290) --= 51450
and datalength(a.phn) = 9
and b.clinicdoctor_id = a.clinicdoctor_id
ORDER BY a.last_name,a.first_name,a.patient_id

OPEN patients_cursor
FETCH NEXT FROM patients_cursor
INTO @full_name, @birth_date, @phn, @patient_id

--select @full_name, @birth_date, @phn, @patient_id


WHILE @@FETCH_STATUS = 0

BEGIN

DECLARE chartcount_cursor CURSOR FOR
select count(*)
from ChartEntries
where patient_id = @patient_id


OPEN chartcount_cursor
FETCH NEXT FROM chartcount_cursor INTO @chart_count

--select @chart_count as chtcount

DECLARE chartentries_cursor CURSOR FOR
select entry_datetime,entry_note
from ChartEntries
where patient_id = @patient_id
order by Patient_id, ChartEntry_Id desc

-- Variable value from the outer cursor

OPEN chartentries_cursor
FETCH NEXT FROM chartentries_cursor INTO @entry_date,@entry_note
--select @entry_date,@entry_note

WHILE @@FETCH_STATUS = 0

BEGIN
set @rec_counter = @rec_counter + 1
--select @@FETCH_STATUS as status
IF @@FETCH_STATUS = 0

insert into temp_notes
values (@Clinic_identifier+@phn+'.'
+REPLICATE('0',3),convert(varchar,@rec_counter)+'. '
+REPLICATE('0',3),convert(varchar,@chart_count),
@phn,
@full_name,
@birth_date,
@entry_date,
@entry_note
)

-- Get the next entry note
FETCH NEXT FROM chartentries_cursor INTO @entry_date,@entry_note
--select @entry_date,@entry_note

END
CLOSE chartentries_cursor
DEALLOCATE chartentries_cursor
CLOSE chartcount_cursor
DEALLOCATE chartcount_cursor


set @rec_counter = 0
set @chart_count = 0

-- Get the next patient record
FETCH NEXT FROM patients_cursor
INTO @full_name, @birth_date, @phn, @patient_id

--select @full_name, @birth_date, @phn, @patient_id

-- Get the next chart record count
--FETCH NEXT FROM chartcount_cursor INTO @chart_count
--select @chart_count as chtcount

END

CLOSE patients_cursor
DEALLOCATE patients_cursor

GO

That is when I received the error, so I inserted this command before the insert line but it made no difference.

SET IDENTITY_INSERT temp_notes ON
insert into temp_notes
values (@Clinic_identifier+@phn+'.'
+REPLICATE('0',3),convert(varchar,@rec_counter)+'. '
+REPLICATE('0',3),convert(varchar,@chart_count),
@phn,
@full_name,
@birth_date,
@entry_date,
@entry_note
)

I'm concatenating four different variables together to insert into the column note_id.

What is the problem? I just don't see it. My table definition looks like this.
CREATE TABLE [dbo].[temp_notes](
[temp_Id] [int] IDENTITY(1,1) NOT NULL,
[note_Id] [varchar](24) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[phn] [char](9) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[full_name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[birth_date] [datetime] NULL,
[entry_datetime] [datetime] NULL,
[Entry_Note] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT [PK_temp_notes] PRIMARY KEY CLUSTERED
(
[temp_Id] ASC
) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

View 2 Replies View Related

Msg 4305, Level 16, State 1, Line 1

Dec 4, 2007

Error 4305

What would be the cause of this error?

Msg 4305, Level 16, State 1, Line 1
The log in this backup set begins at LSN 8229000000047200001, which is too recent to apply to the database. An earlier log backup that includes LSN 8219000000021400001 can be restored

And what would the fix be?

I am trying to restore from a Full Backup and then the log files on a development machine.

Cheers,

Casey

View 5 Replies View Related

Error: Msg 102, Level 15, State 1, Line 1

Aug 2, 2007

Hi,

I have built a stored procedure and the code is like below:





Code Snippet

DECLARE @Table_Name VARCHAR(100)
DECLARE @Table_Desc SQL_VARIANT
DECLARE @Query VARCHAR(8000)

USE HRD

SELECT @Table_Name = 'Employee'

SELECT @Query = 'IF EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N''[dbo].[DEL_' + UPPER(@Table_Name) + ']''))
DROP TRIGGER [dbo].[DEL_' + UPPER(@Table_Name) + ']'
EXEC(@Query)

SELECT @Table_Desc = (SELECT a.value
FROM
sys.extended_properties a, sys.tables b
WHERE a.major_id = b.object_id
AND a.minor_id = 0
AND a.name = 'MS_DESCRIPTION'
AND b.name = @Table_Name)

SELECT @Query = '''CREATE TRIGGER [DEL_' + UPPER(@Table_Name) + '] ON dbo.' + @Table_Name + '
FOR DELETE
AS

DECLARE @Old_Value VARCHAR(8000)
DECLARE @New_Value VARCHAR(8000)
DECLARE @P_Key VARCHAR(8000)
DECLARE @P_Key_Value VARCHAR(8000)
DECLARE @P_Key_Insert VARCHAR(8000)
DECLARE @Comment VARCHAR(8000)

SELECT @P_Key_Insert = ''''''''

EXEC(''''IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N''''''''[dbo].[Temp_PrimKey]'''''''') AND type in (N''''''''U''''''''))
DROP TABLE [dbo].[Temp_PrimKey]'''')

SELECT K.COLUMN_NAME INTO Temp_PrimKey
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS T
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE K
ON T.CONSTRAINT_NAME = K.CONSTRAINT_NAME
WHERE
T.CONSTRAINT_TYPE = ''''PRIMARY KEY'''' AND T.TABLE_NAME = ''''' + @Table_Name + '''''

EXEC(''''IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N''''''''[dbo].[Temp_Value]'''''''') AND type in (N''''''''U''''''''))
DROP TABLE [dbo].[Temp_Value]'''')

EXEC(''''CREATE TABLE [dbo].[Temp_Value](
[PValue] [VARCHAR](max) NOT NULL
) ON [PRIMARY]'''')

EXEC(''''IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N''''''''[dbo].[Temp_Deleted]'''''''') AND type in (N''''''''U''''''''))
DROP TABLE [dbo].[Temp_Deleted]'''')

SELECT * INTO Temp_Deleted FROM deleted

DECLARE Curs_PrimKey CURSOR FOR
SELECT * FROM Temp_PrimKey

OPEN Curs_PrimKey
FETCH NEXT FROM Curs_PrimKey INTO @P_Key
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC(''''INSERT INTO Temp_Value SELECT ''''+ @P_Key + '''' FROM Temp_Deleted'''')
SELECT @P_Key_Value = (SELECT PValue FROM Temp_Value)
EXEC(''''DELETE FROM Temp_Value'''')
SELECT @P_Key_Insert = @P_Key_Insert + @P_Key + '''' = '''' + @P_Key_Value + '''', ''''
FETCH NEXT FROM Curs_PrimKey INTO @P_Key
END
CLOSE Curs_PrimKey
DEALLOCATE Curs_PrimKey

EXEC(''''IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N''''''''[dbo].[Temp_Deleted]'''''''') AND type in (N''''''''U''''''''))
DROP TABLE [dbo].[Temp_Deleted]'''')

EXEC(''''IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N''''''''[dbo].[Temp_Value]'''''''') AND type in (N''''''''U''''''''))
DROP TABLE [dbo].[Temp_Value]'''')

SELECT @P_Key_Insert = LEFT(@P_Key_Insert, LEN(@P_Key_Insert)-2)
SELECT @Comment = ''''' + CAST(@Table_Desc AS VARCHAR) + ' deleted, '''' + @P_Key_Insert

INSERT INTO TLOG(Log_Date, Log_Reference, Log_Comment)
VALUES (GETDATE(), @P_Key_Insert, @Comment)
'''
--PRINT @Query
EXEC(@Query)
Problem is when I run it gives error:

Msg 102, Level 15, State 1, Line 1Incorrect syntax near 'CREATE TRIGGER [DEL_EMPLOYEE] ON dbo.Employee FOR DELETEAS DECLARE @Old_Value VARCHAR(8000)DECLARE @New_Value VARCHA'.

If I print the @Query and run it in a query analyzer using the statement EXEC it worked. It's giving me headache, this supposed to be a simple exec statement. Please advise. Thanks.

View 2 Replies View Related

Msg 3710, Level 16, State 1, Line 1

Jul 19, 2006

Hello Folks,



I am moving the model & Msdb databases to a different location and I have this error.

Thanks

Msg 3710, Level 16, State 1, Line 1

Cannot detach an opened database when the server is in minimally configured mode.

View 3 Replies View Related

Server: Msg 1101, Level 17, State 10, Line 8

Jan 25, 2002

If we run the query below with the values of 'rml' and 'ra' it runs but if we use 'cca' and 'cc' we get this error:

Server: Msg 1101, Level 17, State 10, Line 8
Could not allocate new page for database 'TEMPDB'. There are no more pages available in filegroup DEFAULT. Space can be created by dropping objects, adding additional files, or allowing file growth.

Here is the query

Declare @Level_1 varchar(3),
@Level_2 varchar(2)

Select @Level_1 = 'cca'
Select @Level_2 = 'cc'

select distinct tblAsset.State, tblAsset.County, tblAsset.Plant, tblAsset.Account,
tblAsset.Acq_Yr, tblAsset.Acq_Pd, tblAsset_Book.Cost_Original,
tblCounty_Names.County_Name, CER..tblLocation.Location,
tblGL_Account.Account_Desc

from tblAsset, tblAsset_Book, tblCounty_Names, CER..tblLocation, tblGL_Account
where tblAsset_Book.Level_1 = @Level_1
and tblAsset.Level_1 = tblAsset_Book.Level_1
and tblAsset_Book.Level_2 = @Level_2
and tblAsset.Level_2 = tblAsset_Book.Level_2
and tblGL_Account.Company = tblAsset.Level_2
and CER..tblLocation.SBU = tblGL_Account.Company
and tblCounty_Names.County = tblAsset.County
and CER..tblLocation.County = tblCounty_Names.County
and CER..tblLocation.Code = tblAsset.Plant
and tblGL_Account.Account = tblAsset.Account
and tblAsset_Book.Book_Number = '1'
order by tblAsset.State

View 1 Replies View Related

Help : Server: Msg 8152, Level 16, State 9, Line 1

Jan 5, 2001

When I try to update one table from another I get the following error
message, Does anyone know what may be the cause of the error :

Server: Msg 8152, Level 16, State 9, Line 1
String or binary data would be truncated.
The statement has been terminated.

Thanks

KUL

View 2 Replies View Related

Server: Msg 2511, Level 16, State 1, Line 1

Feb 9, 2006

Dear All participants.

My distribution log file size is reached upto 33GB, What I should do?

Any clue or helps are too appreciable.

Thanks
R.Mall

View 3 Replies View Related

Server: Msg 2537, Level 16, State 43, Line 1

Aug 25, 2007

i have sp4 install. Anyone know how to fix it?

Server: Msg 2537, Level 16, State 43, Line 1
Table error: Object ID 1376776012, index ID 0, page (1:56868), row 2. Record check (Valid SqlVariant) failed. Values are 7 and 0.
Server: Msg 2537, Level 16, State 1, Line 1 ... so on

=============================
http://www.sqlserverstudy.com

View 9 Replies View Related

SQL Server Msg 1105, Level 17, State 2, Line 1

Nov 23, 2005

Dear (and mighty) all:I backed up a database (SQL server 7.0) and tried to restore it onanother system (SQL Server 2000). This is not the first time I'm doingthis and never had a problem before:-- in the source dbBACKUP db_icoaraci TO DISK = 'C:TEMPBACKUP-ICOARACI.DAT'--in the destination dbRESTORE db_icoaraci FROM DISK='E:TEMPBACKUP-ICOARACI.DAT'WITH MOVE='ICOARACI_DAT' TO 'E:DBICOARACI.MDF',MOVE='ICOARACI_LOG' TO 'E:DBICOARACI.LDF'Today, to my surprise, the destination SQL returned the followingerror:Processed 25592 pages for database 'db_icoaraci', file 'ICOARACI_DAT'on file 1.Processed 1 pages for database 'db_icoaraci', file 'ICOARACI_LOG' onfile 1.Server: Msg 1105, Level 17, State 2, Line 1Could not allocate space for object '(SYSTEM table id: 6)' in database'db_icoaraci' because the 'PRIMARY' filegroup is full.Server: Msg 3013, Level 16, State 1, Line 1RESTORE DATABASE is terminating abnormally.I searched the list and a found a few posts refering to the same error,but none in the exactly same scenario.I tried to restore the database with NORECOVERY, and, before restoringthe log, increase its size (ALTER DATABASE ... etc), but SQL Serversays that the DB couldn't be open because it's in the middle of arestore...I'll appreciate any help.Regards,Branco.

View 3 Replies View Related

Server: Msg 8152, Level 16, State 6, Line 196

Dec 17, 2007

I am experiencing some frustration in regards to parsing an email that I need to work with.
(I don't have control over the format of the email I am receiving)

Any help would be appreciated.
Thank you
Jake

Here is the error I get, when I use the SQL Query Analyzer to process my Stored Procedure. (Not every email gets this error, just some, others process just fine.)

String or binary data would be truncated.
The statement has been terminated.
Stored Procedure: eResponse.dbo.spParser
Return Code = -6

My Code is as follows:

CREATE PROCEDURE spParser
@_id nvarchar(50)
AS
--assumes the email is no longer than 4000 characters. if it might be longer, bump this number up.
-- Common Varriables
DECLARE @body nvarchar(4000)
DECLARE @i int
DECLARE @phone nvarchar(50)
DECLARE @phonestart int
DECLARE @phoneend int
DECLARE @email nvarchar(50)
DECLARE @emailstart int
DECLARE @emailend int
DECLARE @comments nvarchar(3000)
DECLARE @commentsstart int
DECLARE @commentsend int
DECLARE @OrigID varchar(50)
-- Jose Ole Variables
DECLARE @firstname nvarchar(50)
DECLARE @firstnamestart int
DECLARE @firstnameend int
DECLARE @lastname nvarchar(50)
DECLARE @lastnamestart int
DECLARE @lastnameend int
DECLARE @address1 nvarchar(50)
DECLARE @address1start int
DECLARE @address1end int
DECLARE @address2 nvarchar(50)
DECLARE @address2start int
DECLARE @address2end int
DECLARE @city nvarchar(50)
DECLARE @citystart int
DECLARE @cityend int
DECLARE @state nvarchar(5)
DECLARE @statestart int
DECLARE @stateend int
DECLARE @zip nvarchar(15)
DECLARE @zipstart int
DECLARE @zipend int
DECLARE @country nvarchar(50)
DECLARE @countrystart int
DECLARE @countryend int
DECLARE @phone2 nvarchar(50)
DECLARE @phone2start int
DECLARE @phone2end int
DECLARE @productname nvarchar(50)
DECLARE @productnamestart int
DECLARE @productnameend int
DECLARE @upccode nvarchar(50)
DECLARE @upccodestart int
DECLARE @upccodeend int
DECLARE @datecode nvarchar(50)
DECLARE @datecodestart int
DECLARE @datecodeend int
DECLARE @purchaseat nvarchar(50)
DECLARE @purchaseatstart int
DECLARE @purchaseatend int
DECLARE @purchasecity nvarchar(50)
DECLARE @purchasecitystart int
DECLARE @purchasecityend int
DECLARE @datepurchased nvarchar(50)
DECLARE @datepurchasedstart int
DECLARE @datepurchasedend int
DECLARE @dateopened nvarchar(50)
DECLARE @dateopenedstart int
DECLARE @dateopenedend int
DECLARE @subject nvarchar(50)
DECLARE @subjectstart int
DECLARE @subjectend int
-- Windosr Variables
DECLARE @name nvarchar(50)
DECLARE @namestart int
DECLARE @nameend int
DECLARE @company nvarchar(50)
DECLARE @companystart int
DECLARE @companyend int

--First replace all ASCII carriage returns and line feeds and assign the whole chunk of data to a variable.
SET @body = (select replace( REPLACE(convert(varchar(4000), message),CHAR(10),' '),CHAR(13),'') from message where mailid = @_id)
--below is the sample syntax for the individual replacements of line feeds and carriage returns, but it's combined into one statement above.
--SELECT REPLACE(@jb,CHAR(10),'') as firstpass
--SELECT REPLACE(@jb,CHAR(13),'') as secondpass
IF left(@body,47) = 'Fromubject:contact info sent from samplesite.com'
--If this is true.. then it is a sample company.
BEGIN
--The 12 in the start is compensating for the 12 Characters of "First Name: "
--Below is collecting First Name
SET @firstnamestart = (CHARINDEX('First name:',@body) + 11)
SET @firstnameend = (CHARINDEX('Last name:',@body) - 1)
SET @firstname = SUBSTRING(@body,@firstnamestart,@firstnameend-@firstnamestart)
----Below is collecting Last Name
SET @lastnamestart = (CHARINDEX('Last name:',@body) + 10)
SET @lastnameend = (CHARINDEX('Address 1:',@body) - 1)
SET @lastname = SUBSTRING(@body,@lastnamestart,@lastnameend-@lastnamestart)
--Below is collecting Address1
SET @address1start = (CHARINDEX('Address 1:',@body) + 10)
SET @address1end = (CHARINDEX('Address 2:',@body) - 1)
SET @address1 = SUBSTRING(@body,@address1start,@address1end-@address1start)
--Below is collecting Address2
SET @address2start = (CHARINDEX('Address 2:',@body) + 10)
SET @address2end = (CHARINDEX('City:',@body) - 1)
SET @address2 = SUBSTRING(@body,@address2start,@address2end-@address2start)
--Below is collecting city information
SET @citystart = (CHARINDEX('City:',@body) + 5)
SET @cityend = (CHARINDEX('State/Prov',@body) -1)
SET @city = SUBSTRING(@body,@citystart,@cityend-@citystart)
--Below is collecting state information
SET @statestart = (CHARINDEX('State/Province:',@body) + 15)
SET @stateend = (CHARINDEX('Zip/Postal',@body) -1)
SET @state = SUBSTRING(@body,@statestart,@stateend-@statestart)
--Below is collecting zip information
SET @zipstart = (CHARINDEX('Zip/Postal Code:',@body) + 16)
SET @zipend = (CHARINDEX('Country',@body) -1)
SET @zip = SUBSTRING(@body,@zipstart,@zipend-@zipstart)
--Below is collecting country information
SET @countrystart = (CHARINDEX('Country:',@body) + 8)
SET @countryend = (CHARINDEX('E-mail address',@body) -1)
SET @country = SUBSTRING(@body,@countrystart,@countryend-@countrystart)
--Below is collecting email information
SET @emailstart = (CHARINDEX('E-mail address:',@body) + 15)
SET @emailend = (CHARINDEX('Daytime',@body) -1)
SET @email = SUBSTRING(@body,@emailstart,@emailend-@emailstart)
--Below is collecting phone information
SET @phonestart = (CHARINDEX('Daytime Phone:',@body) + 14)
SET @phoneend = (CHARINDEX('Evening Phone:',@body) -1)
SET @phone = SUBSTRING(@body,@phonestart,@phoneend-@phonestart)
--Below is collecting phone2 information
SET @phone2start = (CHARINDEX('Evening Phone:',@body) + 14)
SET @phone2end = (CHARINDEX('Product Name',@body) -1)
SET @phone2 = SUBSTRING(@body,@phone2start,@phone2end-@phone2start)
--Below is collecting Product Name information
SET @productnamestart = (CHARINDEX('Product Name:',@body) + 12)
SET @productnameend = (CHARINDEX('UPC Code:',@body) -1)
SET @productname = SUBSTRING(@body,@productnamestart,@productnameend-@productnamestart)
--Below is collecting UPC Code information
SET @upccodestart = (CHARINDEX('UPC Code:',@body) + 9)
SET @upccodeend = (CHARINDEX('Date Code:',@body) -1)
SET @upccode = SUBSTRING(@body,@upccodestart,@upccodeend-@upccodestart)
--Below is collecting Date Code information
SET @datecodestart = (CHARINDEX('Date Code:',@body) + 10)
SET @datecodeend = (CHARINDEX('Purchased At',@body) -1)
SET @datecode = SUBSTRING(@body,@datecodestart,@datecodeend-@datecodestart)
--Below is collecting Purchase At information
SET @purchaseatstart = (CHARINDEX('Purchased At',@body) + 26)
SET @purchaseatend = (CHARINDEX('Purchase City:',@body) -1)
SET @purchaseat = SUBSTRING(@body,@purchaseatstart,@purchaseatend-@purchaseatstart)
--Below is collecting Purchase City information
SET @purchasecitystart = (CHARINDEX('Purchase City:',@body) + 14)
SET @purchasecityend = (CHARINDEX('Date Purchased',@body) -1)
SET @purchasecity = SUBSTRING(@body,@purchasecitystart,@purchasecityend-@purchasecitystart)
--Below is collecting Date Purchased information
SET @datepurchasedstart = (CHARINDEX('Date Purchased:',@body) + 15)
SET @datepurchasedend = (CHARINDEX('Date Opened',@body) -1)
SET @datepurchased = SUBSTRING(@body,@datepurchasedstart,@datepurchasedend-@datepurchasedstart)
--Below is collecting Date Opened information
SET @dateopenedstart = (CHARINDEX('Date Opened:',@body) + 12)
SET @dateopenedend = (CHARINDEX('E-mail Subject:',@body) -1)
SET @dateopened = SUBSTRING(@body,@dateopenedstart,@dateopenedend-@dateopenedstart)
--Below is collecting Email Subject information
SET @subjectstart = (CHARINDEX('E-mail Subject:',@body) + 15)
SET @subjectend = (CHARINDEX('Comments:',@body) -1)
SET @subject = SUBSTRING(@body,@subjectstart,@subjectend-@subjectstart)
--Below is collecting message information
SET @commentsstart = (CHARINDEX('Comments:',@body) + 10)
SET @commentsend = len(@body)
SET @comments = SUBSTRING(@body,@commentsstart,@commentsend-@commentsstart)
--below is the part that actually writes the data out to the Output table
INSERT INTO OutputEmails
(FirstName, LastName, Address1, Address2, City, State, Zip, Country, eMail, Phone, Phone2, ProductName, UPCCode, DateCode, PurchaseAt, PurchaseCity, DatePurchased, DateOpened, Subject, Comments, OrigID)
SELECT
ltrim(SUBSTRING(@body,@firstnamestart,@firstnameend-@firstnamestart)) as FirstName,
ltrim(SUBSTRING(@body,@lastnamestart,@lastnameend-@lastnamestart)) as LastName,
ltrim(SUBSTRING(@body,@address1start,@address1end-@address1start)) as Address1,
ltrim(SUBSTRING(@body,@address2start,@address2end-@address2start)) as Address2,
ltrim(SUBSTRING(@body,@citystart,@cityend-@citystart)) as City,
ltrim(SUBSTRING(@body,@statestart,@stateend-@statestart)) as State,
ltrim(SUBSTRING(@body,@zipstart,@zipend-@zipstart)) as Zip,
ltrim(SUBSTRING(@body,@countrystart,@countryend-@countrystart)) as Country,
ltrim(SUBSTRING(@body,@emailstart,@emailend-@emailstart)) as eMail,
ltrim(SUBSTRING(@body,@phonestart,@phoneend-@phonestart)) as Phone,
ltrim(SUBSTRING(@body,@phone2start,@phone2end-@phone2start)) as Phone2,
ltrim(SUBSTRING(@body,@productnamestart,@productnameend-@productnamestart)) as ProductName,
ltrim(SUBSTRING(@body,@upccodestart,@upccodeend-@upccodestart)) as UPCCode,
ltrim(SUBSTRING(@body,@datecodestart,@datecodeend-@datecodestart)) as DateCode,
ltrim(SUBSTRING(@body,@purchaseatstart,@purchaseatend-@purchaseatstart)) as PurchaseAt,
ltrim(SUBSTRING(@body,@purchasecitystart,@purchasecityend-@purchasecitystart)) as PurchaseCity,
ltrim(SUBSTRING(@body,@datepurchasedstart,@datepurchasedend-@datepurchasedstart)) as DatePurchased,
ltrim(SUBSTRING(@body,@dateopenedstart,@dateopenedend-@dateopenedstart)) as DateOpened,
ltrim(SUBSTRING(@body,@subjectstart,@subjectend-@subjectstart)) as Subject,
ltrim(SUBSTRING(@body,@commentsstart,@commentsend-@commentsstart)) as Comments,
@_id as OrigID
FROM dbo.message
WHERE (mailId = @_id)
END
ELSE BEGIN
--below prints the whole value in the debugger (SQL Query Analyzer)
--print @body
--below prints the length of the whole value
--print len(@body)
--below prints the location of 'Callers Name:'
--Print CHARINDEX('Name: ',@body)
--Below is collecting the Name information
--The 6 in the start is compensating for the 6 Characters of "Name: "
SET @namestart = (CHARINDEX('Name:',@body) + 5)
SET @nameend = (CHARINDEX('Email:',@body) - 1)
SET @name = SUBSTRING(@body,@namestart,@nameend-@namestart)
--Below is collecting email information
SET @emailstart = (CHARINDEX('Email:',@body) + 6)
SET @emailend = (CHARINDEX('Title:',@body) -1)
SET @email = SUBSTRING(@body,@emailstart,@emailend-@emailstart)
--Below is collecting Company information
SET @companystart = (CHARINDEX('Company:',@body) + 8)
SET @companyend = (CHARINDEX('Phone Number:',@body) -1)
SET @company = SUBSTRING(@body,@companystart,@companyend-@companystart)
--Below is collecting phone information
SET @phonestart = (CHARINDEX('Phone Number:',@body) + 13)
SET @phoneend = (CHARINDEX('Comments:',@body) -1)
SET @phone = SUBSTRING(@body,@phonestart,@phoneend-@phonestart)
--Below is collecting message information
SET @commentsstart = (CHARINDEX('Comments:',@body) + 9)
SET @commentsend = len(@body)
SET @comments = SUBSTRING(@body,@commentsstart,@commentsend-@commentsstart)
--below is the part that actually writes the data out to the Output table
INSERT INTO OutputEmails
(Name, eMail, Company, Phone, Comments, OrigID)
SELECT
ltrim(SUBSTRING(@body,@namestart,@nameend-@namestart)) as Name,
ltrim(SUBSTRING(@body,@emailstart,@emailend-@emailstart)) as eMail,
ltrim(SUBSTRING(@body,@companystart,@companyend-@companystart)) as Company,
ltrim(SUBSTRING(@body,@phonestart,@phoneend-@phonestart)) as Phone,
ltrim(SUBSTRING(@body,@commentsstart,@commentsend-@commentsstart)) as Comments,
@_id as OrigID
FROM dbo.message
WHERE (mailId = @_id)
END
--At the very end when you're satisfied that the data has been processed properly, delete the appropriate message record from the message table
DELETE FROM MESSAGE Where message.mailID = @_ID
GO

Sample Data that has problems

Fromubject:contact info sent from samplesite.comBody:First name: Sample
Last name: Name
Address 1: 123 Testing Road
Address 2: Don't filled
City: Park Forest
State/Province: FL
Zip/Postal Code: 12345-1234
Country: USA
E-mail address: validemail@email.com
Daytime Phone: 123-123-1234
Evening Phone: Don't filled
Product Name: Sample Product with Cheese
UPC Code: 12345-89521
Date Code: 1251237 D PST . 5290
Purchased At (Store Name): StoreName
Purchase City: Store City
Date Purchased: 12/8/2007
Date Opened: 12/14/2007
E-mail Subject: nail in product
Comments: when I purchased your product, there was something in it. Obviously I am not happy about this. Please contact me. Thank you John Q Public

View 6 Replies View Related

CLR TVF Error: Msg 6260, Level 16, State 1, Line 1

Aug 7, 2007

Dear All, I always got this error in CLR TVF:

Msg 6260, Level 16, State 1, Line 1
An error occurred while getting new row from user defined Table Valued Function :
System.InvalidOperationException: Invalid attempt to FieldCount when reader is closed.
System.InvalidOperationException:
at System.Data.SqlClient.SqlDataReaderSmi.get_FieldCount()
at System.Data.Common.DbEnumerator.BuildSchemaInfo()
at System.Data.Common.DbEnumerator.MoveNext()

Here is my code:

using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
using System.Collections;

public static class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "rowfiller",DataAccess=DataAccessKind.Read,TableDefinition = "ActID int, ActName nvarchar(50), ActCreatorID int,ActDesp nvarchar(200),ActCreateDate datetime,ActModifyDate datetime, ActStartDate datetime, ActEndDate datetime, Status int, Cost int")]
public static IEnumerable Func_GetSchCatActivityIDTable(int CatActivityID)
{
using (SqlConnection connection = new SqlConnection("context connection=true"))
{
string sqlstring = "select * from Activity where CatActivityID=@CatActivityID;";

connection.Open();
SqlCommand command = new SqlCommand(sqlstring, connection);
command.Parameters.AddWithValue("@CatActivityID", CatActivityID);


return command.ExecuteReader(CommandBehavior.CloseConnection);

}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft Performance","CA1811:AvoidUncalledPrivateCode")]
public static void rowfiller(Object obj,
out SqlInt32 ActID,
out SqlString ActName,
out SqlInt32 ActCreatorID,
out SqlString ActDesp,
out SqlDateTime ActCreateDate,
out SqlDateTime ActModifyDate,
out SqlDateTime ActStartDate,
out SqlDateTime ActEndDate,
out SqlInt32 Status,
out SqlInt32 Cost,
)
{

SqlDataRecord row = (SqlDataRecord)obj;
int column = 0;

ActID = (row.IsDBNull(column)) ? SqlInt32.Null : new SqlInt32(row.GetInt32(column)); column++;
ActName = (row.IsDBNull(column)) ? SqlString.Null : new SqlString(row.GetString(column)); column++;
ActCreatorID = (row.IsDBNull(column)) ? SqlInt32.Null : new SqlInt32(row.GetInt32(column)); column++;
ActDesp = (row.IsDBNull(column)) ? SqlString.Null : new SqlString(row.GetString(column)); column++;
ActCreateDate = (row.IsDBNull(column)) ? SqlDateTime.Null : new SqlDateTime(row.GetDateTime(column)); column++;
ActModifyDate = (row.IsDBNull(column)) ? SqlDateTime.Null : new SqlDateTime(row.GetDateTime(column)); column++;
ActStartDate = (row.IsDBNull(column)) ? SqlDateTime.Null : new SqlDateTime(row.GetDateTime(column)); column++;
ActEndDate = (row.IsDBNull(column)) ? SqlDateTime.Null : new SqlDateTime(row.GetDateTime(column)); column++;
Status = (row.IsDBNull(column)) ? SqlInt32.Null : new SqlInt32(row.GetInt32(column)); column++;
Cost = (row.IsDBNull(column)) ? SqlInt32.Null : new SqlInt32(row.GetInt32(column)); column++;
}


};

Can anyone tell me what I am doing wrong? Many thanks

.

View 8 Replies View Related

Msg 102, Level 15, State 1, Procedure Dni_invoices_get, Line 37

Feb 20, 2007



Hello,



I am using SQL express as a backend for my websites and my accounting software.

When installing my new app I run the install.sql file and all is good untill the end.

the following error occurs. Can someone direct me where to look to fix this please?

Msg 102, Level 15, State 1, Procedure dni_invoices_get, Line 37

Incorrect syntax near '.'.



Thanks eveningjazz

View 3 Replies View Related

Msg 15600, Level 15, State 1, Procedure Sp_change_users_login, Line 207

Jun 20, 2007

I restored a database to my test server from a production server. I ran "sp_change_users_login 'report' " and found 1 orphan id. Then I ran "sp_change_users_login 'auto_fix', 'orphan_id' ". It gets the error. I have run it before with success. Any idea why this time is different?

View 4 Replies View Related

Msg 15151, Level 16, State 1, Line 5 (Cannot Find The User)

Apr 26, 2007

I'm getting a specific error when i try to run a .sql script for a Custom TableProfile from the Asp.net site,when i Parse the .sql file Commands execute perfectly. But when i actually "Execute" the .sql script i get the following errors::



Msg 15151, Level 16, State 1, Line 5

Cannot find the user 'WYATT-PCWyattASPNET', because it does not exist or you do not have permission.







How can i fix this??







Thxs in Advance Rattlerr

View 6 Replies View Related

Msg 4104, Level 16, State 1, Line 1 In Update Query

Feb 25, 2008

Msg 4104, Level 16, State 1, Line 1

The multi-part identifier "dbo.JOB40115_Cost_Actindx.ACTINDX" could not be bound.



UPDATE dbo.JOB40115 set dbo.JOB40115.JOB_Cost_Index = dbo.JOB40115_Cost_Actindx.ACTINDX

SELECT JOB40115.ProjctID, JOB40115.SubLevel1, JOB40115.SubLevel2, JOB40115.CostCategorie, JOB40115.DepartementID, JOB40115.JOB_Cost_Index,

JOB40115_Cost_Actindx.ACTINDX, JOB40115_Cost_Actindx.ProjctID AS Expr1, JOB40115_Cost_Actindx.SubLevel1 AS Expr2,

JOB40115_Cost_Actindx.SubLevel2 AS Expr3, JOB40115_Cost_Actindx.DepartementID AS Expr4,

JOB40115_Cost_Actindx.CostCategorie AS Expr5

FROM JOB40115 INNER JOIN

JOB40115_Cost_Actindx ON JOB40115.ProjctID = JOB40115_Cost_Actindx.ProjctID AND

JOB40115.SubLevel1 = JOB40115_Cost_Actindx.SubLevel1 AND JOB40115.SubLevel2 = JOB40115_Cost_Actindx.SubLevel2 AND

JOB40115.CostCategorie = JOB40115_Cost_Actindx.CostCategorie AND JOB40115.DepartementID = JOB40115_Cost_Actindx.DepartementID

View 1 Replies View Related

Line 1: Incorrect Syntax Near

Jun 6, 2006

Hello All,

Me saying " has any body come across such error would be
underestimating".

Well I am getting a very peculiar and unique error "Line 1: Incorrect
syntax near 'Actions'."

Explaining you the scene is the following Stored Proc.

This stored proc is execute from a VB code in the .net application as
like: -
{Try
Connection.Init_Variables()
cn.ConnectionString = Connection.gstrConnection
ResDb.ConnectionString = Connection.gresConnection
cn.Open()
With sqlCmd
.Connection = cn
.CommandText = "DSP_Get_Required"
.CommandType = CommandType.StoredProcedure

.Parameters.Add("@ActionId", SqlDbType.Int, 9).Value = ActionID
.Parameters("@ActionId").Direction = ParameterDirection.InputOutput

.Parameters.Add("@PersonID", SqlDbType.Int, 9).Value = PersonID
.Parameters("@PersonID").Direction = ParameterDirection.InputOutput

.Parameters.Add("@ReturnMessage", SqlDbType.VarChar, 1000).Value =
ReturnMessage.ToString
.Parameters("@ReturnMessage").Direction =
ParameterDirection.InputOutput

.Parameters.Add("@Exists", SqlDbType.Bit, 1).Value = Exists
.Parameters("@Exists").Direction = ParameterDirection.InputOutput

.Parameters.Add("@Days", SqlDbType.Int, 9).Value = 0
.Parameters("@Days").Direction = ParameterDirection.InputOutput

.Parameters.Add("@StartDate", SqlDbType.DateTime).Value = Now()
.Parameters("@StartDate").Direction = ParameterDirection.InputOutput

.Parameters.Add("@EndDate", SqlDbType.DateTime).Value = Now()
.Parameters("@EndDate").Direction = ParameterDirection.InputOutput

.Parameters.Add("@OutCome", SqlDbType.VarChar, 20).Value = "Stop"
.Parameters("@OutCome").Direction = ParameterDirection.InputOutput

.Parameters.Add("@Evaluate", SqlDbType.Int, 9).Value = 0
.Parameters("@Evaluate").Direction = ParameterDirection.InputOutput

.Parameters.Add("@DbName", SqlDbType.VarChar, 100).Value =
ResDb.Database.ToString
.Parameters("@DbName").Direction = ParameterDirection.InputOutput

.ExecuteReader(CommandBehavior.Default)
}

On Execution I get the subjected Error "Line 1: Incorrect syntax near
'Actions'." Any Ideas from your all experience to get away from this error will be
helpful. Look forward to read somebody soon.

Stored Proc:-
{SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID =
OBJECT_ID(N'dbo.DSP_Get_Required_ActionS') AND OBJECTPROPERTY(id,
N'ISPROCEDURE') = 1)
DROP PROCEDURE dbo.DSP_Get_Required_ActionS
GO

CREATE PROCEDURE DSP_Get_Required_ActionS
@ActionID INT OUTPUT,
@PersonID INT OUTPUT,
@ReturnMessage Varchar(1000) OUTPUT,
@Exists BIT OUTPUT,
@Days INT OUTPUT,
@StartDate DATETIME OUTPUT,
@EndDate DATETIME OUTPUT,
@OutCome VARCHAR(20) OUTPUT,
@Evaluate INT OUTPUT,
@DbName VARCHAR(100) OUTPUT
AS

SET NOCOUNT ON


--DECLARE @PopulateSQL AS NVarchar(4000)

DECLARE @Rule_ID AS NUMERIC(9)
DECLARE @Curr_ActionSubType AS VARCHAR(20)
DECLARE @Eval_SubType AS VARCHAR(20)
-- DECLARE @OutCome AS VARCHAR(20)
-- DECLARE @Evaluate AS INT
-- DECLARE @Days AS INT
DECLARE @Message AS VARCHAR(1000)
DECLARE @Mandatory AS BIT

-- This is the variable used to interpret the Precedant subtype
DECLARE @Prec_Subtype AS VARCHAR(20)

-- DECLARE @Exists AS BIT --this is supposed to be the deceision maker
variable to be used within the precedant check.

DECLARE @Precedant_SubTypes_Cnt AS INT --This is the variable used to
recordcount the Precedant Subtypes to be checked
DECLARE @Counter AS INT -- Counter used to loop through the Table of
precedant Subtypes.
DECLARE @ROWCOUNT AS INT -- Temporary ROWCOUNT

SET @Counter = 1

--Process to retrive @Curr_ActionSubType Variable
CREATE TABLE #Curr_ActionSubType(ActionSubType VARCHAR(100))
EXEC ('INSERT INTO #Curr_ActionSubType SELECT SubType FROM '+ @DbName
+'.resadm.action WHERE '+@DbName+'.resadm.action.Actionid = '+
@ActionID+' AND ' +@DbName+'.resadm.action.status =''A''')

SET @Curr_ActionSubType = (Select ActionSubType from #Curr_ActionSubType)
DROP TABLE #Curr_ActionSubType

--Process to retrive @StartDate Variable
CREATE TABLE #StartDate(StartDate DATETIME)
EXEC('INSERT INTO #StartDate SELECT CONVERT(DATETIME,
'+@DbName+'.Resadm.Action.DateofAction + '' ''+
'+@DbName+'.Resadm.Action.TimeOfAction)
FROM '+@DbName+'.resadm.action
WHERE '+@DbName+'.resadm.action.Actionid = '+ @ActionID +' AND '+@DbName+'.resadm.action.status =''A''' )

SET @StartDate = (Select StartDate from #StartDate)
DROP TABLE #StartDate

SET @Rule_ID = (SELECT Rule_ID FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY RULE_ID)
SET @Eval_SubType = (SELECT Evaluate_Subtype FROM Rules WHERE
Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY
Evaluate_Subtype)
SET @OutCome = (SELECT OutCome FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY OutCome)
SET @Evaluate = (SELECT Evaluate FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY Evaluate)
SET @Days = (SELECT Days FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY Days)
SET @Message = (SELECT Message FROM Rules WHERE Curr_Subtype =
@Curr_ActionSubType and Status <>0 GROUP BY Message)
SET @Mandatory = (SELECT Optional_Mandatory_Precedant FROM Rules WHERE
Curr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BY
Optional_Mandatory_Precedant)

-- create the temporary table for the Subtypes to be evaluated
CREATE TABLE #Preceding_SubTypes_Details
( SubTypes_LIST_ID INT IDENTITY (1, 1) NOT NULL,
RULE_ID NUMERIC(9),
SubType VARCHAR(20),
)

-- insert the current subtype that needs to be evaluated.
INSERT INTO #Preceding_SubTypes_Details
SELECT Rule_ID, Prec_Subtype
FROM Rules_Details
WHERE Rule_ID = @Rule_ID

-- create the History table for Reference
--sk/* Modified to accomodatethe need ot dynamic database name to
retrive from the different Resman databases
CREATE TABLE #dsHistory ( ActionID INT,
PersonID INT,
ActionTypeID VARCHAR(1),
DateofAction DATETIME,
Status VARCHAR(1),
Subtype VARCHAR(6),
ActionTypeName VARCHAR(30),
ActionSubtypeID VARCHAR(6),
EffectCandidateCurrentState VARCHAR(10),
TaxCode VARCHAR(6)
)
EXEC ('INSERT INTO #dsHistory SELECT
'+@DbName+'.Resadm.Action.ActionID, '
+ @DbName+'.Resadm.Action.PersonID,
'+@DbName+'.Resadm.Action.ActionTypeID, '
+ 'CONVERT(DATETIME, '+@DbName+'.Resadm.Action.DateofAction + '' ''+
'+@DbName+'.Resadm.Action.TimeOfAction)DateofAction, '
+ @DbName+'.Resadm.Action.Status, '+@DbName+'.Resadm.Action.Subtype, '
+ @DbName+'.ResAdm.Action_Types.ActionTypeName,
'+@DbName+'.Resadm.Action_subtypes.ActionSubtypeID, '
+ @DbName+'.Resadm.Action_subtypes.EffectCandidateCurrentState,
'+@DbName+'.Resadm.Person.TaxCode '
+ ' FROM '+@DbName+'.Resadm.Action '
+ ' INNER JOIN '+@DbName+'.ResAdm.Action_Types WITH(NOLOCK) '
+ ' ON '+@DbName+'.ResAdm.Action_Types.ActionTypeID =
'+@DbName+'.Resadm.Action.ActionTypeID '
+ ' INNER JOIN '+@DbName+'.ResAdm.Action_SubTypes WITH(NOLOCK) '
+ ' ON '+@DbName+'.Resadm.Action.subtype =
'+@DbName+'.ResAdm.Action_SubTypes.actionsubtypeid '
+ ' INNER JOIN '+@DbName+'.Resadm.Person WITH(NOLOCK) '
+ ' ON '+@DbName+'.Resadm.Person.PersonID =
'+@DbName+'.Resadm.Action.PersonID '
+ ' WHERE '+@DbName+'.Resadm.Action.actionID <>
CONVERT(VARCHAR,'+@ActionID+')'
+ ' AND '+@DbName+'.Resadm.Action.PersonID =
CONVERT(VARCHAR,'+@PersonID+')'
+ ' AND '+@DbName+'.Resadm.Action.Status =''A'' '
+ 'AND (CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction +''
''+ '+@DbName+'.Resadm.Action.TimeOfAction) > '
+ ' ISNULL(( SELECT
MAX(CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction + '' ''+ '
+ @DbName+'.Resadm.Action.TimeOfAction)) '
+ ' FROM '+@DbName+'.Resadm.Action '
+ ' WHERE ('+@DbName+'.Resadm.Action.PersonID =
CONVERT(VARCHAR,'+@PersonID+')) AND '
+ ' ('+@DbName+'.Resadm.Action.Subtype =''ZERO'') '
+ ' AND ('+@DbName+'.Resadm.Action.Status=''A'')),0)) '
+ ' ORDER BY CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction +
'' ''+ '+@DbName+'.Resadm.Action.TimeOfAction )DESC, ActionID DESC')


--sk*/
SET @EndDate = (SELECT ISNULL((SELECT DateOfAction
FROM #dsHistory
WHERE SubType = @Eval_SubType), getdate()))


-- set the rowcount to retrieve the number of check to be carried out


SET @Precedant_SubTypes_Cnt = (SELECT COUNT(*) FROM
#Preceding_SubTypes_Details)


WHILE @Counter <= @Precedant_SubTypes_Cnt
BEGIN
SET @Prec_Subtype = (SELECT SubType from #Preceding_SubTypes_Details
WHERE SubTypes_LIST_ID = @Counter)


SET @ROWCOUNT = (SELECT COUNT(*) FROM #dsHistory WHERE Subtype =
@Prec_Subtype)


IF @ROWCOUNT > 0
BEGIN
SET @Exists = 1
END


IF @ROWCOUNT = 0
BEGIN
IF @Mandatory = 1
BEGIN
SET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; '
SET @Counter = @Precedant_SubTypes_Cnt
SET @Exists = 0
END
ELSE IF @Mandatory = 0
BEGIN
SET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; '
SET @Exists = @Exists
END
END


SET @Counter = @Counter+1
END


IF @Exists = 0
BEGIN
EXEC(
' UPDATE '+@DbName+'.Resadm.Action '
+ ' SET '+@DbName+'.Resadm.Action.Status = ''I'' '
+ ' WHERE '+@DbName+'.Resadm.Action.ActionID = '+@ActionID+' SET
@ReturnMessage = '+@Message
)
END
ELSE
IF @Exists = 1
BEGIN
SET @ReturnMessage = @Message
END


IF @Rule_ID = Null
BEGIN
SET @ReturnMessage = 'Validation Rule Not Present'
END
-- Select 'Exist value : ', @Exists, 'Return message is : ',
@ReturnMessage
DROP TABLE #Preceding_SubTypes_Details
DROP TABLE #dshistory

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO}

View 1 Replies View Related

Line 1: Incorrect Syntax Near '='

Aug 4, 2005

Hi,I'm getting the above error when i try to fill a Dataset through adataAdapter.I presume it is to do with the sql statement. Below is the relevantcode:string strPntUnitID = patientCodeLbl.Text;string strPntFName = fNameLbl.Text;string strPntLName = lNameLbl.Text;// Create DataAdapter & DatasetSqlDataAdapter daRelateDocToPnt = new SqlDataAdapter("SELECT patientNo,doctorNo FROM tblPatient" +"WHERE (pntUnitID = '"+ strPntUnitID +"') AND (pntFName = '"+strPntFName +"')"+"AND (pntLName = '"+ strPntLName +"')", conn);DataSet dsDocNoToPnt = new DataSet();// Create command builder, automatically generates the update commandsSqlCommandBuilder pntCmd = new SqlCommandBuilder(daRelateDocToPnt);// Set the MissingSchemaAction property to AddWithKey because Fill willnot cause primary// key & unique key information to be retrieved unless AddWithKey isspecified.daRelateDocToPnt.MissingSchemaAction = MissingSchemaAction.AddWithKey;// Use dataAdapter to fill DataSetdaRelateDocToPnt.Fill(dsDocNoToPnt, "Patient");// place intDocNo into the dataset schemadsDocNoToPnt.Tables["Patient"].Rows[0]["doctorNo"] = "intDocNo";// Update The DatabasedaRelateDocToPnt.Update(dsDocNoToPnt, "Patient");Can anyone spot the problem?Thanks

View 3 Replies View Related

Line 1: Incorrect Syntax Near

Jun 6, 2006

Hello All,Me saying " has any body come across such error would beunderestimating".Well I am getting a very peculiar and unique error "Line 1: Incorrectsyntax near 'Actions'."Explaining you the scene is the following Stored Proc.This stored proc is execute from a VB code in the .net application aslike: -{TryConnection.Init_Variables()cn.ConnectionString = Connection.gstrConnectionResDb.ConnectionString = Connection.gresConnectioncn.Open()With sqlCmd..Connection = cn..CommandText = "DSP_Get_Required".CommandType = CommandType.StoredProcedure..Parameters.Add("@ActionId", SqlDbType.Int, 9).Value = ActionID..Parameters("@ActionId").Direction = ParameterDirection.InputOutput..Parameters.Add("@PersonID", SqlDbType.Int, 9).Value = PersonID..Parameters("@PersonID").Direction = ParameterDirection.InputOutput..Parameters.Add("@ReturnMessage", SqlDbType.VarChar, 1000).Value =ReturnMessage.ToString..Parameters("@ReturnMessage").Direction =ParameterDirection.InputOutput..Parameters.Add("@Exists", SqlDbType.Bit, 1).Value = Exists..Parameters("@Exists").Direction = ParameterDirection.InputOutput..Parameters.Add("@Days", SqlDbType.Int, 9).Value = 0..Parameters("@Days").Direction = ParameterDirection.InputOutput..Parameters.Add("@StartDate", SqlDbType.DateTime).Value = Now()..Parameters("@StartDate").Direction = ParameterDirection.InputOutput..Parameters.Add("@EndDate", SqlDbType.DateTime).Value = Now()..Parameters("@EndDate").Direction = ParameterDirection.InputOutput..Parameters.Add("@OutCome", SqlDbType.VarChar, 20).Value = "Stop"..Parameters("@OutCome").Direction = ParameterDirection.InputOutput..Parameters.Add("@Evaluate", SqlDbType.Int, 9).Value = 0..Parameters("@Evaluate").Direction = ParameterDirection.InputOutput..Parameters.Add("@DbName", SqlDbType.VarChar, 100).Value =ResDb.Database.ToString..Parameters("@DbName").Direction = ParameterDirection.InputOutput..ExecuteReader(CommandBehavior.Default)}On Execution I get the subjected Error "Line 1: Incorrect syntax near'Actions'."Any Ideas from your all experience to get away from this error will behelpful. Look forward to read somebody soon.Stored Proc:-{SET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS OFFGOIF EXISTS (SELECT * FROM dbo.sysobjects WHERE ID =OBJECT_ID(N'dbo.DSP_Get_Required_ActionS') AND OBJECTPROPERTY(id,N'ISPROCEDURE') = 1)DROP PROCEDURE dbo.DSP_Get_Required_ActionSGOCREATE PROCEDURE DSP_Get_Required_ActionS@ActionID INT OUTPUT,@PersonID INT OUTPUT,@ReturnMessage Varchar(1000) OUTPUT,@Exists BIT OUTPUT,@Days INT OUTPUT,@StartDate DATETIME OUTPUT,@EndDate DATETIME OUTPUT,@OutCome VARCHAR(20) OUTPUT,@Evaluate INT OUTPUT,@DbName VARCHAR(100) OUTPUTASSET NOCOUNT ON--DECLARE @PopulateSQL AS NVarchar(4000)DECLARE @Rule_ID AS NUMERIC(9)DECLARE @Curr_ActionSubType AS VARCHAR(20)DECLARE @Eval_SubType AS VARCHAR(20)-- DECLARE @OutCome AS VARCHAR(20)-- DECLARE @Evaluate AS INT-- DECLARE @Days AS INTDECLARE @Message AS VARCHAR(1000)DECLARE @Mandatory AS BIT-- This is the variable used to interpret the Precedant subtypeDECLARE @Prec_Subtype AS VARCHAR(20)-- DECLARE @Exists AS BIT --this is supposed to be the deceision makervariable to be used within the precedant check.DECLARE @Precedant_SubTypes_Cnt AS INT--This is the variable used torecordcount the Precedant Subtypes to be checkedDECLARE @Counter AS INT -- Counter used to loop through the Table ofprecedant Subtypes.DECLARE @ROWCOUNT AS INT -- Temporary ROWCOUNTSET @Counter = 1--Process to retrive @Curr_ActionSubType VariableCREATE TABLE #Curr_ActionSubType(ActionSubType VARCHAR(100))EXEC ('INSERT INTO #Curr_ActionSubType SELECT SubType FROM '+ @DbName+'.resadm.action WHERE '+@DbName+'.resadm.action.Actionid = '+@ActionID+' AND ' +@DbName+'.resadm.action.status =''A''')SET @Curr_ActionSubType = (Select ActionSubType from#Curr_ActionSubType)DROP TABLE #Curr_ActionSubType--Process to retrive @StartDate VariableCREATE TABLE #StartDate(StartDate DATETIME)EXEC('INSERT INTO #StartDate SELECT CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofAction + '' ''+'+@DbName+'.Resadm.Action.TimeOfAction)FROM '+@DbName+'.resadm.actionWHERE '+@DbName+'.resadm.action.Actionid = '+ @ActionID +' AND'+@DbName+'.resadm.action.status =''A''')SET @StartDate = (Select StartDate from #StartDate)DROP TABLE #StartDateSET @Rule_ID = (SELECT Rule_ID FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY RULE_ID)SET @Eval_SubType = (SELECT Evaluate_Subtype FROM Rules WHERECurr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BYEvaluate_Subtype)SET @OutCome = (SELECT OutCome FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY OutCome)SET @Evaluate = (SELECT Evaluate FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Evaluate)SET @Days = (SELECT Days FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Days)SET @Message = (SELECT Message FROM Rules WHERE Curr_Subtype =@Curr_ActionSubType and Status <>0 GROUP BY Message)SET @Mandatory = (SELECT Optional_Mandatory_Precedant FROM Rules WHERECurr_Subtype = @Curr_ActionSubType and Status <>0 GROUP BYOptional_Mandatory_Precedant)-- create the temporary table for the Subtypes to be evaluatedCREATE TABLE #Preceding_SubTypes_Details(SubTypes_LIST_ID INT IDENTITY (1, 1) NOT NULL,RULE_ID NUMERIC(9),SubType VARCHAR(20),)-- insert the current subtype that needs to be evaluated.INSERT INTO #Preceding_SubTypes_DetailsSELECT Rule_ID, Prec_SubtypeFROM Rules_DetailsWHERE Rule_ID = @Rule_ID-- create the History table for Reference--sk/*Modified to accomodatethe need ot dynamic database name toretrive from the different Resman databasesCREATE TABLE #dsHistory ( ActionID INT,PersonID INT,ActionTypeID VARCHAR(1),DateofAction DATETIME,Status VARCHAR(1),Subtype VARCHAR(6),ActionTypeName VARCHAR(30),ActionSubtypeID VARCHAR(6),EffectCandidateCurrentState VARCHAR(10),TaxCode VARCHAR(6))EXEC ('INSERT INTO #dsHistory SELECT'+@DbName+'.Resadm.Action.ActionID, '+ @DbName+'.Resadm.Action.PersonID,'+@DbName+'.Resadm.Action.ActionTypeID, '+ 'CONVERT(DATETIME, '+@DbName+'.Resadm.Action.DateofAction + '' ''+'+@DbName+'.Resadm.Action.TimeOfAction)DateofActio n, '+ @DbName+'.Resadm.Action.Status, '+@DbName+'.Resadm.Action.Subtype, '+ @DbName+'.ResAdm.Action_Types.ActionTypeName,'+@DbName+'.Resadm.Action_subtypes.ActionSubtypeID , '+ @DbName+'.Resadm.Action_subtypes.EffectCandidateCu rrentState,'+@DbName+'.Resadm.Person.TaxCode '+ ' FROM '+@DbName+'.Resadm.Action '+ ' INNER JOIN '+@DbName+'.ResAdm.Action_Types WITH(NOLOCK) '+ ' ON '+@DbName+'.ResAdm.Action_Types.ActionTypeID ='+@DbName+'.Resadm.Action.ActionTypeID '+ ' INNER JOIN '+@DbName+'.ResAdm.Action_SubTypes WITH(NOLOCK) '+ ' ON '+@DbName+'.Resadm.Action.subtype ='+@DbName+'.ResAdm.Action_SubTypes.actionsubtypeid '+ ' INNER JOIN '+@DbName+'.Resadm.Person WITH(NOLOCK) '+ ' ON '+@DbName+'.Resadm.Person.PersonID ='+@DbName+'.Resadm.Action.PersonID '+ ' WHERE '+@DbName+'.Resadm.Action.actionID <>CONVERT(VARCHAR,'+@ActionID+')'+ ' AND '+@DbName+'.Resadm.Action.PersonID =CONVERT(VARCHAR,'+@PersonID+')'+ ' AND '+@DbName+'.Resadm.Action.Status =''A'' '+ 'AND (CONVERT(DATETIME,'+@DbName+'.Resadm.Action.Dateof Action +''''+ '+@DbName+'.Resadm.Action.TimeOfAction) > '+ ' ISNULL(( SELECTMAX(CONVERT(DATETIME,'+@DbName+'.Resadm.Action.Dat eofAction + '' ''+ '+ @DbName+'.Resadm.Action.TimeOfAction)) '+ ' FROM '+@DbName+'.Resadm.Action '+ ' WHERE ('+@DbName+'.Resadm.Action.PersonID =CONVERT(VARCHAR,'+@PersonID+')) AND '+ ' ('+@DbName+'.Resadm.Action.Subtype =''ZERO'') '+ ' AND ('+@DbName+'.Resadm.Action.Status=''A'')),0)) '+ ' ORDER BY CONVERT(DATETIME,'+@DbName+'.Resadm.Action.DateofA ction +'' ''+ '+@DbName+'.Resadm.Action.TimeOfAction )DESC, ActionID DESC')--sk*/SET @EndDate = (SELECT ISNULL((SELECT DateOfActionFROM #dsHistoryWHERE SubType = @Eval_SubType), getdate()))-- set the rowcount to retrieve the number of check to be carried outSET @Precedant_SubTypes_Cnt = (SELECT COUNT(*) FROM#Preceding_SubTypes_Details)WHILE @Counter <= @Precedant_SubTypes_CntBEGINSET @Prec_Subtype = (SELECT SubType from #Preceding_SubTypes_DetailsWHERE SubTypes_LIST_ID = @Counter)SET @ROWCOUNT = (SELECT COUNT(*) FROM #dsHistory WHERE Subtype =@Prec_Subtype)IF @ROWCOUNT > 0BEGINSET @Exists = 1ENDIF @ROWCOUNT = 0BEGINIF @Mandatory = 1BEGINSET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; 'SET @Counter = @Precedant_SubTypes_CntSET @Exists = 0ENDELSE IF @Mandatory = 0BEGINSET @Message = @Message + ' ' + @Prec_Subtype + ' Is Missing; 'SET @Exists = @ExistsENDENDSET @Counter = @Counter+1ENDIF @Exists = 0BEGINEXEC(' UPDATE '+@DbName+'.Resadm.Action '+ ' SET '+@DbName+'.Resadm.Action.Status = ''I'' '+ ' WHERE '+@DbName+'.Resadm.Action.ActionID = '+@ActionID+' SET@ReturnMessage = '+@Message)ENDELSEIF @Exists = 1BEGINSET @ReturnMessage = @MessageENDIF @Rule_ID = NullBEGINSET @ReturnMessage = 'Validation Rule Not Present'END-- Select 'Exist value : ', @Exists, 'Return message is : ',@ReturnMessageDROP TABLE #Preceding_SubTypes_DetailsDROP TABLE #dshistoryGOSET QUOTED_IDENTIFIER OFFGOSET ANSI_NULLS ONGO}

View 1 Replies View Related

I Am Getting Line 202:Incorrect Syntax Near 'end'

May 30, 2007

Hi Marc,



I have a similar problem as mentioned in the first mail of this chain. I am getting Line 202:Incorrect syntax near 'end'" while I try to execute the procedure from my VC++ code using

ExecuteNonQuery method.



can you guide me about solving this issue?



Regards,

Anni

View 2 Replies View Related

Line 1: Incorrect Syntax Near.......

Sep 13, 2006

Hi,

Uses: Sql server 2000, asp.net 1.1;

I've the following Stored Procedure:

<SQL Code>
CREATE PROCEDURE PABX_sp_MyPABX_ShowExtWatch
@FromDate DATETIME,
@ToDate DATETIME,
@PortalID INT = 1,
@UserID INT
AS
SELECT PABX_Ext_Watch.ExtNo As ExtNo, COUNT(*) AS Calls, SUM(PABX_Calls.Rate) AS NetAmt
FROM PABX_Ext_Watch
INNER JOIN PABX_Calls
ON PABX_Ext_Watch.ExtNo = PABX_Calls.ExtNo
INNER JOIN PABX_PortalUsers
ON PABX_Ext_Watch.PortalUserID = PABX_PortalUsers.PortalUserID
AND PABX_Calls.PortalID = PABX_PortalUsers.PortalID
WHERE PABX_Calls.sTime >= CONVERT(DATETIME, @FromDate, 102)
AND PABX_Calls.eTime <= CONVERT(DATETIME, @ToDate, 102)
AND PABX_PortalUsers.uID = @UserID
AND PABX_PortalUsers.PortalID = @PortalID
GROUP BY PABX_Ext_Watch.ExtNo
GO
</SQL Code>

However if I execute this stored procedure in asp.net I get the following error, despite the stored procedure executed successfully in query analyzer:

Line 1: Incorrect Syntax Near ......

When I check the sql profiler the stored procedure is been executed in this way:

exec sp_executesql N'PABX_sp_MYPABX_ShowExtWatch', N'@FromDate datetime,@ToDate datetime,@UserID int,@PortalID int', @FromDate = 'Sep 1 2006 12:00:00:000AM', @ToDate = 'Sep 30 2006 12:00:00:000AM', @UserID = 207, @PortalID = 2

I couldn't figure it out though sql server management console and query analyzer showed no signs of errors. I sense that the sql is not being executed correctly with letters as "N" in the sql profiler.

Could anyone help me out on this?

Thanks & Regards,


View 6 Replies View Related

Database Mirror Error Msg 1447, Level 16, State 21, Line 1

Feb 19, 2007

we config our SAP system to use SQL Server 2005 database mirror. but the mirror server hang by accident, after restart mirror server,the server return to normal,but the mirror can't be resume.

ALTER DATABASE R3P
SET PARTNER resume

the error is:
Msg 1447, Level 16, State 21, Line 1
ALTER DATABASE "R3P" command cannot be executed until both partner server instances are up, running, and connected. Start the partner and reissue the command.

View 2 Replies View Related

Management Studio Disconnects With Error Msg 0, Level 11, State 0, Line 0

Nov 3, 2006

I am trying to run the following:

select * from sysindexes

The operation begins and results are produced but after about 200 results, I get the error - Msg 0, Level 11, State 0, Line 0 - and it disconnects.

This is a DB moved (restored) from SQL 2000 to SQL 2005.

Any ideas would be appreciated. I am the "make do" DBA and not very good at it yet, I am afraid.

Regards,

Mike







View 8 Replies View Related

Line 1: Incorrect Syntax Near 'getlistofspclass'.

Jul 29, 2006

what am i doing wrong.. :(
 
CREATE PROCEDURE getlistofspclass(@date datetime,@s varchar(8000) output)
AS
select @s = coalesce(@s + ' & ', '') + '"' + convert(varchar(10),dbo.calader.timestart)+ ' ' + dbo.classT.classname + '<p>'FROM  dbo.calader INNER JOIN  dbo.classT ON dbo.calader.classid = dbo.classT.classcodeWHERE  dbo.calader.caledardatedates = @dateexec( @s)GO

View 6 Replies View Related

Line 1: Incorrect Syntax Near 'GetUserRoles'.

Mar 4, 2004

Hi;

I am trying to prepare a login page.My code first controls if user exists in database with GetUser stored procedure then if he/she exists getting the roles assigned to that user with GetUserRoles procedure but I am taking this error
Line 1: Incorrect syntax near 'GetUserRoles'.

GetUserRoles Procedure:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER Procedure GetUserRoles
(
@UserName char(10),
@Roles char(10) Output
)
As
Select @Roles=RoleID From UserRoles Where
UserID=@UserName
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

My ASP.NET Code:

.......................
SqlParameter SQLParm=new SqlParameter();
SQLStr=new SqlCommand("GetUser",Con.GetConnection);
SQLStr.CommandType=CommandType.StoredProcedure;
SQLParm=SQLStr.Parameters.Add("ReturnValue",SqlDbType.Int);
SQLParm.Direction=ParameterDirection.ReturnValue;
SQLStr.Parameters.Add("@UserName",txtuser.Text);
SQLStr.Parameters.Add("@Pass",txtpass.Text);
Con.GetConnection.Open();
SQLStr.ExecuteNonQuery();
Returned=Convert.ToInt32(SQLStr.Parameters["ReturnValue"].Value);
if(Returned==1)
{
SQLStr=new SqlCommand("GetUserRoles",Con.GetConnection);
SQLStr.Parameters.Add("@UserName",txtuser.Text);
SQLParm=SQLStr.Parameters.Add("@Roles",SqlDbType.Char);
SQLParm.Size=50;
SQLParm.Direction=ParameterDirection.Output;
SQLStr.ExecuteNonQuery();
Roles=Convert.ToString(SQLStr.Parameters["@Roles"].Value);
LblMsg.Text=Roles;
Con.GetConnection.Close();
}
............................
............................

Thank you for your replies from now....

View 6 Replies View Related

Error-Line 1: Incorrect Syntax Near '='

Aug 21, 2004

hi,

i got this error when i run app.

---------------
Line 1: Incorrect syntax near '='.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '='.

Source Error:


Line 40: Dim adpt As New SqlDataAdapter("SELECT * FROM SMS_student_class_master WHERE" & _
Line 41: "stud_id=" & sid, con)
Line 42: adpt.Fill(ds, "SMS_student_class_master")
Line 43: txt.Text = ds.Tables.Item("roll_no").ToString
Line 44: con.Close()


Source File: c:inetpubwwwrootaspnetsmsassignment_d.aspx.vb Line: 42
--------

what should i do?
anyone have any idea?
plz give solution.
it's urgent.

thanks in advance

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved