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
 General SQL Server Forums
 New to SQL Server Programming
 generate this result

Author  Topic 

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2011-09-28 : 13:53:44
do u know how I can generate something like this?.
result:
exec dbo.cCount @StartDate='Sep 24 2011 12:00AM', @EndDate='Sep 24 2011 11:59:59PM', @FeedID = 10


declare @table1 table (id int, name varchar(25), datatype varchar(25), value varchar(25))
insert @table1
select 1, '@startdate', 'datetime', 'Sep 22 2011 12:00AM' union all
select 1, '@enddate', 'datetime', 'Sep 22 2011 12:00AM' union all
select 1, '@feedid', 'int', '9'

declare @table2 table (id int, sqlstatement varchar(100))
insert @table2
select 1, 'dbo.cCount'

select * from @table1
select * from @table2

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-28 : 13:59:10
Why don't use 'Sep 25 2011' for @EndDate and use < (not <=) in your code? I'm pretty sure visakh suggested this to you in your other thread.

By the way, exec dbo.cCount... is not a result. It's a call to a stored procedure. If you are asking how to form the parameter values, then you'll need to help us with what programming language you are using.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2011-09-28 : 14:05:50
Sorry but i have to use the time....
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-28 : 14:30:45
Then use 'Sep 25 2011 12:00AM' and use <.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-09-28 : 14:55:00
Not 100% sure what you are asking for, but all signs point to a nightmare. But, maybe this will help?:
SELECT 
'EXEC '
+ T2.sqlstatement
+STUFF((
SELECT DISTINCT TOP 100 PERCENT
+ ', ' + T1.Name
+ ' = '
+ CASE
WHEN Datatype = 'datetime' THEN CHAR(39) + CONVERT(VARCHAR(50), CONVERT(DATETIME, Value, 100), 126) + CHAR(39)
WHEN datatype = 'int' THEN CAST(Value AS VARCHAR(50))
ELSE ''
END
FROM
@Table1 AS T1
WHERE
T1.ID = T2.ID
FOR XML PATH('')
), 1, 1, '') AS SqlString
FROM
@Table2 AS T2
Edit: Forgot commas
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-28 : 14:56:09
The OP is using "result" incorrectly.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -