Showing posts with label names. Show all posts
Showing posts with label names. Show all posts

Wednesday, March 28, 2012

How to validate report server URL?

Hi,
My application is using reporting services reports. This application has
got some settings where service URL and report folder names are stored. My
requirement is to validate report server URL.
E.g. rptURL = http://REPORTBOX/REPORTSERVER.
where REPORTBOX is the machine name.
Here I want to validate whether rptURL is valid or not.
How do I do that from c# code?
thanks,
DeeeYou can just create an instance of the webservice object, authenticate by
setting the Credentials property, and call a method. Wrap everything in a
try/catch.
--
Adrian M.
MCP
"Deee" <Deee@.discussions.microsoft.com> wrote in message
news:691D0A2C-A3A8-4961-B5DB-4A903FD6FA14@.microsoft.com...
> Hi,
> My application is using reporting services reports. This application has
> got some settings where service URL and report folder names are stored.
> My
> requirement is to validate report server URL.
> E.g. rptURL = http://REPORTBOX/REPORTSERVER.
> where REPORTBOX is the machine name.
> Here I want to validate whether rptURL is valid or not.
> How do I do that from c# code?
> thanks,
> Deeesql

Friday, February 24, 2012

how to use a variable to reference database names

Hi, I found your email address from discuss you posted on
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47384
I need to have a query like below to run to select all the fields from
different databases that each database have a table named 'table1'
select * from test...table1
select * from test1..table1
I have the following code sample:
declare @.dbname varchar(50)
set @.dbname='test'
select @.dbname
select * from @.dbname..table1
However I received the error messge when I ran this code. Can anyone
help to resolve this?
ThanksThats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.|||set nocount on
go
set transaction isolation level read uncommitted
go
set quoted_identifier off
go
declare @.dbname varchar(128)
declare @.table varchar (128)
set @.table='table1'
declare cr_opendb cursor fast_forward for select name from
master.dbo.sysdatabases
open cr_opendb
fetch next from cr_opendb into @.dbname
while @.@.fetch_status = 0
begin
EXEC ("select b.name from "+@.dbname+".dbo.sysobjects a join
"+@.dbname+".dbo.syscolumns b on a.id=b.id where a.name='"+@.table+"'")
fetch next from cr_opendb into @.dbname
end
close cr_opendb
deallocate cr_opendb|||foru123 schrieb:
> Hi, I found your email address from discuss you posted on
> http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47384
> I need to have a query like below to run to select all the fields from
> different databases that each database have a table named 'table1'
> select * from test...table1
> select * from test1..table1
> I have the following code sample:
> declare @.dbname varchar(50)
> set @.dbname='test'
> select @.dbname
> select * from @.dbname..table1
> However I received the error messge when I ran this code. Can anyone
> help to resolve this?
> Thanks
>
Dynamic SQL is what you are looking for. Look at "sp_executesql" in the
SQL Server BOL:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_ea-ez_2h7w.asp
hth
Stefka|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.|||set nocount on
go
set transaction isolation level read uncommitted
go
set quoted_identifier off
go
declare @.dbname varchar(128)
declare @.table varchar (128)
set @.table='table1'
declare cr_opendb cursor fast_forward for select name from
master.dbo.sysdatabases
open cr_opendb
fetch next from cr_opendb into @.dbname
while @.@.fetch_status = 0
begin
EXEC ("select b.name from "+@.dbname+".dbo.sysobjects a join
"+@.dbname+".dbo.syscolumns b on a.id=b.id where a.name='"+@.table+"'")
fetch next from cr_opendb into @.dbname
end
close cr_opendb
deallocate cr_opendb|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.

how to use a variable to reference database names

Hi, I found your email address from discuss you posted on
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47384
I need to have a query like below to run to select all the fields from
different databases that each database have a table named 'table1'
select * from test...table1
select * from test1..table1
I have the following code sample:
declare @.dbname varchar(50)
set @.dbname='test'
select @.dbname
select * from @.dbname..table1
However I received the error messge when I ran this code. Can anyone
help to resolve this?
Thanks
Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.
|||set nocount on
go
set transaction isolation level read uncommitted
go
set quoted_identifier off
go
declare @.dbname varchar(128)
declare @.table varchar (128)
set @.table='table1'
declare cr_opendb cursor fast_forward for select name from
master.dbo.sysdatabases
open cr_opendb
fetch next from cr_opendb into @.dbname
while @.@.fetch_status = 0
begin
EXEC ("select b.name from "+@.dbname+".dbo.sysobjects a join
"+@.dbname+".dbo.syscolumns b on a.id=b.id where a.name='"+@.table+"'")
fetch next from cr_opendb into @.dbname
end
close cr_opendb
deallocate cr_opendb
|||foru123 schrieb:
> Hi, I found your email address from discuss you posted on
> http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47384
> I need to have a query like below to run to select all the fields from
> different databases that each database have a table named 'table1'
> select * from test...table1
> select * from test1..table1
> I have the following code sample:
> declare @.dbname varchar(50)
> set @.dbname='test'
> select @.dbname
> select * from @.dbname..table1
> However I received the error messge when I ran this code. Can anyone
> help to resolve this?
> Thanks
>
Dynamic SQL is what you are looking for. Look at "sp_executesql" in the
SQL Server BOL:
http://msdn.microsoft.com/library/de...ea-ez_2h7w.asp
hth
Stefka
|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.
|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.
|||set nocount on
go
set transaction isolation level read uncommitted
go
set quoted_identifier off
go
declare @.dbname varchar(128)
declare @.table varchar (128)
set @.table='table1'
declare cr_opendb cursor fast_forward for select name from
master.dbo.sysdatabases
open cr_opendb
fetch next from cr_opendb into @.dbname
while @.@.fetch_status = 0
begin
EXEC ("select b.name from "+@.dbname+".dbo.sysobjects a join
"+@.dbname+".dbo.syscolumns b on a.id=b.id where a.name='"+@.table+"'")
fetch next from cr_opendb into @.dbname
end
close cr_opendb
deallocate cr_opendb
|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.
|||Could not figure out why I am getting this error message when executing
your following code. If you scroll down the message tab you will see the
following error message:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '3'.
*** Sent via Developersdex http://www.codecomments.com ***
|||Never mind. The error message comes from a database name started with a
number.
*** Sent via Developersdex http://www.codecomments.com ***

how to use a variable to reference database names

Hi, I found your email address from discuss you posted on
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47384
I need to have a query like below to run to select all the fields from
different databases that each database have a table named 'table1'
select * from test...table1
select * from test1..table1
I have the following code sample:
declare @.dbname varchar(50)
set @.dbname='test'
select @.dbname
select * from @.dbname..table1
However I received the error messge when I ran this code. Can anyone
help to resolve this?
ThanksThats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.|||set nocount on
go
set transaction isolation level read uncommitted
go
set quoted_identifier off
go
declare @.dbname varchar(128)
declare @.table varchar (128)
set @.table='table1'
declare cr_opendb cursor fast_forward for select name from
master.dbo.sysdatabases
open cr_opendb
fetch next from cr_opendb into @.dbname
while @.@.fetch_status = 0
begin
EXEC ("select b.name from "+@.dbname+".dbo.sysobjects a join
"+@.dbname+".dbo.syscolumns b on a.id=b.id where a.name='"+@.table+"'")
fetch next from cr_opendb into @.dbname
end
close cr_opendb
deallocate cr_opendb|||foru123 schrieb:
> Hi, I found your email address from discuss you posted on
> http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=47384
> I need to have a query like below to run to select all the fields from
> different databases that each database have a table named 'table1'
> select * from test...table1
> select * from test1..table1
> I have the following code sample:
> declare @.dbname varchar(50)
> set @.dbname='test'
> select @.dbname
> select * from @.dbname..table1
> However I received the error messge when I ran this code. Can anyone
> help to resolve this?
> Thanks
>
Dynamic SQL is what you are looking for. Look at "sp_executesql" in the
SQL Server BOL:
http://msdn.microsoft.com/library/d.../>
ez_2h7w.asp
hth
Stefka|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.|||set nocount on
go
set transaction isolation level read uncommitted
go
set quoted_identifier off
go
declare @.dbname varchar(128)
declare @.table varchar (128)
set @.table='table1'
declare cr_opendb cursor fast_forward for select name from
master.dbo.sysdatabases
open cr_opendb
fetch next from cr_opendb into @.dbname
while @.@.fetch_status = 0
begin
EXEC ("select b.name from "+@.dbname+".dbo.sysobjects a join
"+@.dbname+".dbo.syscolumns b on a.id=b.id where a.name='"+@.table+"'")
fetch next from cr_opendb into @.dbname
end
close cr_opendb
deallocate cr_opendb|||Thats not working, you have to use dynamic sql then:
DECLARE @.SQLString VARCHAR(200)
SET @.dbname='test'
SET @.SQLString = 'SELECT * FROM ' + @.dbname + '..table1'
EXEC(@.SQLString)
HTH, jens Suessmeyer.|||Could not figure out why I am getting this error message when executing
your following code. If you scroll down the message tab you will see the
following error message:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '3'.
*** Sent via Developersdex http://www.codecomments.com ***|||Never mind. The error message comes from a database name started with a
number.
*** Sent via Developersdex http://www.codecomments.com ***

Sunday, February 19, 2012

How to use a Table Variable

Hi all,

I have a table which holds a list of users names & the table assigned to each, e.g.

- John Smith - Table1
- bob Jones - Table2
etc

I have a store procedure which calls the information from the user's table based on the username. Something like this:

Select *
from @.UserTable

So if user is John Smith then @.UserTable = Table1.

Though the @. function does not work for referencing a table. Is there a workaround to this ?

Rgds & thanks.

A think that the only way is using an exec ou sp_executesql like this:

Declare @.command varchar(1000)

Select @.Command = 'Select * From ' + @.UserTable

Exec(@.Command) or sp_executesql @.Command

Regards.

|||Thats worked spot on .. thanks m8 |||How can I take the data from the executed table and put it into a temp table?|||Hi,

Couldn't you federate the username table and the multiple user tables into only one table and

use a stored procedure? That would save you a lot of trouble.

i.e. where you have:

Table_users

User_Name, value_1, Value_2, Value_3
Value 1 to n comes from the multiple user tables

then
Create Procedure up_Users @.User (Varchar(85))

Create table #TUser (Value_1 varchar(320), Value_2 varchar(320), value_3 varchar(320))

Insert Into #TUser(Value_1, Value_2, Value_3)

Select

value_1, Value_2, Value_3

from Table_Users u

Where u.User_Name = @.User

select * from #Tuser

drop table #Tuser

Philippe