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
 query without using parameter

Author  Topic 

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2011-10-03 : 05:04:34
Hi All,

Iam having a query which gives the desired output as shown below :

DECLARE @counter INT=0
SELECT @counter = @counter |CONVERT(INT, RoleID) from UsersRoles where UserID = 23
select @counter as Result

Please let me know the query to show the same result without using parameter.
Thanks,
Ram

rams

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-03 : 05:17:39
[code]SELECT 0 |CONVERT(INT, RoleID) from UsersRoles where UserID = 23[/code]


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2011-10-03 : 05:21:29
Hi Visakh,

SELECT 0 |CONVERT(INT, RoleID) from UsersRoles where UserID = 23
This query returns the values but not the output result :(

rams
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-03 : 05:23:40
what does that mean? whats output result and what its giving?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2011-10-03 : 05:32:49
SELECT 0 |CONVERT(INT, RoleID) from UsersRoles where UserID = 23

this query give the output as :
NoCulumn
-------
4
2

But the output should be :
6,


rams
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-03 : 05:35:38
how do you think it will merge resultset? it will apply it on each row and give result so two rows means 2 values in resultset unless you apply some kind of aggregation

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2011-10-03 : 05:38:26
could you aggregate that and write the query for me..it would be great help

rams
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2011-10-03 : 08:18:40
why don't you give the query a try? help is one thing, doing ALL the work for you is another...

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -