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.
| Author |
Topic |
|
thiyait
Yak Posting Veteran
70 Posts |
Posted - 2004-10-08 : 14:57:45
|
| My need of call is getting the query like thisi needed the query like this so i call the another function to retrive dataSelect @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in ('8','9','10' )Select @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in dbo.GetuserTempid(@PortalId,@userid,@tabid)........this is calling fucntionMy coding follows:First Function 1:CREATE FUNCTION dbo.getfinalresult (@portalid as int ,@userid as int ,@tabid as int) RETURNS nvarchar(100) AS BEGIN declare @tempauth nvarchar(50)declare @id as intdeclare @userIds varchar(100)Select @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in dbo.GetuserTempid(@PortalId,@userid,@tabid)Select @tempauth= '('+@userIds+')'return @tempauthENDsecond function 2:CREATE function GetuserTempid(@PortalId int,@userid int,@tabid int )returns nvarchar(50) asbegindeclare @tempuserid as nvarchar(100)set @Tempuserid =( SELECT '(''' + REPLACE(LEFT(LTRIM(RTRIM(authorizedroles)), LEN(LTRIM(RTRIM(authorizedroles)))-1), ';', ''',''') + ''')' FROM tabs WHERE tabid = @tabid)return @tempuserid /*Tabs table return the query like this :('4','5','5')endNote:Table tabs contain:select authorizedroles from tabs WHERE tabid = @tabidresult:authorizedroles8910but i needed format is ('8','9','10') Function two return the above specified formatSelect @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in dbo.GetuserTempid(@PortalId,@userid,@tabid)/* show the syntax error*/Guys any body help me....... |
|
|
thiyait
Yak Posting Veteran
70 Posts |
Posted - 2004-10-08 : 15:32:17
|
quote: Originally posted by thiyait My need of call is getting the query like thisi needed the query like this so i call the another function to retrive dataSelect @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in ('8','9','10' )Select @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in dbo.GetuserTempid(@PortalId,@userid,@tabid)........this is calling fucntionMy coding follows:First Function 1:CREATE FUNCTION dbo.getfinalresult (@portalid as int ,@userid as int ,@tabid as int) RETURNS nvarchar(100) AS BEGIN declare @tempauth nvarchar(50)declare @id as intdeclare @userIds varchar(100)Select @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in dbo.GetuserTempid(@PortalId,@userid,@tabid)Select @tempauth= '('+@userIds+')'return @tempauthENDsecond function 2:CREATE function GetuserTempid(@PortalId int,@userid int,@tabid int )returns nvarchar(50) asbegindeclare @tempuserid as nvarchar(100)set @Tempuserid =( SELECT '(''' + REPLACE(LEFT(LTRIM(RTRIM(authorizedroles)), LEN(LTRIM(RTRIM(authorizedroles)))-1), ';', ''',''') + ''')' FROM tabs WHERE tabid = @tabid)return @tempuserid /*Tabs table return the query like this :('4','5','5')endNote:Table tabs contain:select authorizedroles from tabs WHERE tabid = @tabidresult:authorizedroles8910but i needed format is ('8','9','10') Function two return the above specified formatSelect @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in dbo.GetuserTempid(@PortalId,@userid,@tabid)/* show the syntax error*/Guys any body help me.......
Dont confuse with huge writtenThis is my need query:............Select @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in ('8','9','10' )Select @userIds = isnull(@userIds+',''','''') + convert(varchar,userId) + '''' from userroles where roleid in dbo.GetuserTempid(@PortalId,@userid,@tabid)?/*.. getusertempid reurn the result......Sql show the error .........help meeeeeeeeeeeeeeee........... |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-10-08 : 15:48:45
|
| What does huge written even mean?Anyway, go to the front page of SQLTeam.com. Type in csv in the article search. You'll find your solution in an article here.Tara |
 |
|
|
|
|
|
|
|