Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Unclosed quotation mark before the character strin

Author  Topic 

sunilsi
Starting Member

21 Posts

Posted - 2009-01-02 : 09:35:39
Friends,



I'm getting error:Unclosed quotation mark before the character string '' with the below SP. Please help



alter procedure GetCalls
(
@value varchar(1)
)

as
begin

declare @curDate datetime,
@cst_date datetime,
@Prev_4_day datetime,
@sqlsel varchar(5000)

set @curDate = getdate()

set @cst_date = dateadd("n",-690,@curDate)


if @value = '1'
begin
set @Prev_4_day = dateadd("d",-4,@cst_date)
set @sqlsel ='select * from tblTrackingMain where status <> ''Closed'' and openTime < ' + @Prev_4_day + ' order by assFullname, severity, userPriority'''
print @sqlsel
execute(@sqlsel)
end

end

Linus

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-02 : 09:41:59
quote:
Originally posted by sunilsi

Friends,



I'm getting error:Unclosed quotation mark before the character string '' with the below SP. Please help



alter procedure GetCalls
(
@value varchar(1)
)

as
begin

declare @curDate datetime,
@cst_date datetime,
@Prev_4_day datetime,
@sqlsel varchar(5000)

set @curDate = getdate()

set @cst_date = dateadd(n,-690,@curDate)


if @value = '1'
begin
set @Prev_4_day = dateadd(d,-4,@cst_date)
set @sqlsel ='select * from tblTrackingMain where status <> ''Closed'' and openTime < ' + @Prev_4_day + ' order by assFullname, severity, userPriority'
print @sqlsel
execute(@sqlsel)
end

end

Linus



modify as above
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2009-01-02 : 09:48:18
you'll also need to make sure your date prints with single quotes, and cast it as a varchar. i.e....


set @sqlsel ='select * from tblTrackingMain where status <> ''Closed'' and openTime < ''' + cast(@Prev_4_day as varchar(25)) + ''' order by assFullname, severity, userPriority'



Em
Go to Top of Page

sunilsi
Starting Member

21 Posts

Posted - 2009-01-02 : 12:06:25
Thank you so much... It works!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-02 : 12:36:32
cheers
Go to Top of Page
   

- Advertisement -