Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

select within exec

Posted on 2010-08-23
7
Medium Priority
?
363 Views
Last Modified: 2012-05-10
is itpossible to hold a select statement within an exec statement, in some other way?

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

thanks
0
Comment
Question by:anushahanna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 668 total points
ID: 33500299
no, that is not possible like this.
I presume you want to "exec" for each row of what is returned?

please clarify
0
 
LVL 8

Assisted Solution

by:kingjely
kingjely earned 668 total points
ID: 33500317
SET @dateski := (select curdate())

Im awsm(not).
Kj
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33500318
I am thinking of appending the current time to a variable string.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 22

Assisted Solution

by:Om Prakash
Om Prakash earned 664 total points
ID: 33500344
Try:

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

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

print @mystring  
0
 
LVL 6

Author Comment

by:anushahanna
ID: 33500359
Thanks.
0
 
LVL 8

Expert Comment

by:kingjely
ID: 33500387


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

 ;)
0
 
LVL 8

Expert Comment

by:kingjely
ID: 33500417
its not possible gets points?
hehe love ur work
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question