Monday, March 26, 2012

Have:DateTime, Need: string, use in EXEC sp_executesql parm list

Hello,
Below is the extract of code I am stuck on. My goal is to take the DateTime
value in the variable @.End and convert it for creating the sp_executesql
params.
The problem:
======================
declare @.End datetime
declare @.E varchar
select @.End=comm_end from CommPeriod
where period_id = (select min(period_id) from CommPeriod
where period_closed = 0 and CountryCode='US')
and CountryCode = 'US'
print @.End
SET @.E = CONVERT(VARCHAR, @.End , 112)
print @.E
The Output:
==================
Dec 31 2004 11:59PM
2
I humbly ask for a solution, clues, tips and...
Thanks,
Bob
> declare @.E varchar
No length specified, implies varchar(1). Make it varchar(8).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Bob B via droptable.com" <forum@.nospam.droptable.com> wrote in message
news:dbba533561de44c18d098a9ec4fb6472@.droptable.co m...
> Hello,
> Below is the extract of code I am stuck on. My goal is to take the DateTime
> value in the variable @.End and convert it for creating the sp_executesql
> params.
> The problem:
> ======================
> declare @.End datetime
> declare @.E varchar
> select @.End=comm_end from CommPeriod
> where period_id = (select min(period_id) from CommPeriod
> where period_closed = 0 and CountryCode='US')
> and CountryCode = 'US'
> print @.End
> SET @.E = CONVERT(VARCHAR, @.End , 112)
> print @.E
> The Output:
> ==================
> Dec 31 2004 11:59PM
> 2
>
> I humbly ask for a solution, clues, tips and...
> Thanks,
> Bob
sql

No comments:

Post a Comment