select within exec

is itpossible to hold a select statement within an exec statement, in some other way?

exec
(
select cast (getdate() as varchar(200))
)

thanks
LVL 6
anushahannaAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
no, that is not possible like this.
I presume you want to "exec" for each row of what is returned?

please clarify
0
 
kingjelyConnect With a Mentor Commented:
SET @dateski := (select curdate())

Im awsm(not).
Kj
0
 
anushahannaAuthor Commented:
I am thinking of appending the current time to a variable string.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Om PrakashConnect With a Mentor Commented:
Try:

declare @mystring varchar(200)
set @mystring  = 'test '

--append current time
select @mystring  = @mystring  + convert(varchar(10),getDate(),108)

print @mystring  
0
 
anushahannaAuthor Commented:
Thanks.
0
 
kingjelyCommented:


good get angelll, and om, give a new kid a break ay !

 ;)
0
 
kingjelyCommented:
its not possible gets points?
hehe love ur work
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.