Showing posts with label startdate. Show all posts
Showing posts with label startdate. Show all posts

Tuesday, March 27, 2012

dynamic query

Hello,

Could anyone please tell me the error in my query...I use sql reporting 2005.

select * from table1 T

where (T.startdate >= Parameters!Startdate.value and

T.startdate <= Parameters!Enddate.value)

The report runs good but does not return any rows.

Thanks,

asiaindian

Hi,

I got it.....

sql

Friday, March 9, 2012

Dynamic Execute in Function?

Is it possible to dynamically execute SQL in a Function?
Set @.selectit = ' Select Startdate from [dbo].[' + @.tablename
+ '] Where testcol=113'
Exec (@.selectit )
Is what I want to do but Query Analyzer won't let me do it.
SQL Server 2000.
Thanks.On Fri, 30 Sep 2005 16:54:52 -0400, xenophon wrote:

>Is it possible to dynamically execute SQL in a Function?
Hi xenophon,
No, that's not possible. See "User-Defined Functions" in Books Online.
Why would you want to do this anyway? Why don't you know the name of
your table?
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||WHO CARES IF IT POSSIBLE?
No programmer who has has a **basic** software engineering course would
use dynamic SQL in the middle of a procedure. Remember the terms
"coupling " and "cohesion"'|||Hello,
You are unable to use it in Function. However, you can use it in stored
procedure. The sample code for your reference:
create proc aaa (@.tablename varchar(10) )
as
begin
declare @.sec varchar(300)
set @.sec= ' Select customerID from ' + @.tablename + ' Where
customerID="ALFKI"'
exec (@.sec)
end
exec aaa 'customers'
I hope the information is helpful.
Sophie Guo
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
========================================
=============
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.

Sunday, February 19, 2012

Dynamic columns

Hi,
Can a column be created dynamically in a table...
For example the user selects start date and enddate and i want to create
columns from startdate to enddate...
Thanks,
Chandra.Chandra,
The simple answer for tables is "No".
What you should be using is a matrix, the columns are dynamic on this.
Chris
CCP wrote:
> Hi,
> Can a column be created dynamically in a table...
> For example the user selects start date and enddate and i want to
> create columns from startdate to enddate...
> Thanks,
> Chandra.