Showing posts with label single. Show all posts
Showing posts with label single. Show all posts

Friday, March 30, 2012

How to control layout of report parameters

I am trying to have lay 3 report parameters in one single row and have
teh next line have just one. In other words, I want to control the
layout of these parameters. How can I do that? I am using Sql Server
2000 Reporting Services.
Also, I wanted to create a checkbox type report parameter.
Thanks.You have no control over this (with any version). You can create your own
front end but if you are using Report Manager then you are pretty much
stuck. There are a few things you can do with style sheets but nothing like
this.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"kulsum" <arif.kulsum@.gmail.com> wrote in message
news:1157051938.689515.234850@.i42g2000cwa.googlegroups.com...
>I am trying to have lay 3 report parameters in one single row and have
> teh next line have just one. In other words, I want to control the
> layout of these parameters. How can I do that? I am using Sql Server
> 2000 Reporting Services.
>
> Also, I wanted to create a checkbox type report parameter.
>
> Thanks.
>|||OK. Thanks Bruce.
Bruce L-C [MVP] wrote:
> You have no control over this (with any version). You can create your own
> front end but if you are using Report Manager then you are pretty much
> stuck. There are a few things you can do with style sheets but nothing like
> this.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "kulsum" <arif.kulsum@.gmail.com> wrote in message
> news:1157051938.689515.234850@.i42g2000cwa.googlegroups.com...
> >I am trying to have lay 3 report parameters in one single row and have
> > teh next line have just one. In other words, I want to control the
> > layout of these parameters. How can I do that? I am using Sql Server
> > 2000 Reporting Services.
> >
> >
> > Also, I wanted to create a checkbox type report parameter.
> >
> >
> > Thanks.
> >

Wednesday, March 28, 2012

How to consolidate multiple rows into a single column

Hello,
I would like some help on developing a SQL query.
I have a Team table and a Person Table. For simplicity sake, lets say
the Team has a key and team name. The Person has a person key, team
key, and person name.
I want to query for all team members, and store the results in a single
column. So, the resulting view would have three columns: team key, team
name, and a list of all people on the team.
Any pointers or tips appreciated,
J Wolfgang GoerlichSELECT T.team_key, T.team_name, P.person_name
FROM Team AS T
JOIN Person AS P
ON T.team_key = P.team_key ;
David Portas
SQL Server MVP
--|||Here is a sample:
=====
CREATE TABLE Team
(
TeamID INT,
TeamName VARCHAR(20)
)
GO
CREATE TABLE Person
(
PersonID INT,
TeamID INT,
PersonName VARCHAR(50)
)
GO
INSERT INTO Team VALUES (1, 'Development')
INSERT INTO Team VALUES (2, 'Release')
INSERT INTO Person VALUES (1, 1, 'Bob')
INSERT INTO Person VALUES (2, 1, 'Mason')
INSERT INTO Person VALUES (3, 2, 'Chris')
INSERT INTO Person VALUES (4, 2, 'Scott')
INSERT INTO Person VALUES (5, 2, 'Bruce')
GO
=====
The above just creates some sample tables and data. Now, we can define a
function that concatenates the list of team members as follows:
=====
IF (OBJECT_ID ('dbo.formTeamList') IS NOT NULL)
DROP FUNCTION dbo.formTeamList
GO
CREATE FUNCTION dbo.formTeamList (@.teamID INT)
RETURNS VARCHAR(8000) AS
BEGIN
DECLARE @.teamList VARCHAR(8000); SET @.teamList = ''
SELECT
@.teamList = @.teamList + ', ' + ISNULL (PersonName, '')
FROM
Person
WHERE
TeamID = @.teamID
RETURN (STUFF (@.teamList, 1, 2, ''))
END
GO
=====
Once done, we can test this out as follows:
=====
SELECT
TeamID, TeamName, dbo.formTeamList (TeamID)
FROM
Team
=====
Although the method shown above works, it is not recommended as there are
limitations:
(1) The function is called for every row in the team table. This can cause
performance problems for large lists.
(2) The function can only concatenate a list of 8000 characters in length
(4000 if you are using UniCode).
Such logic is usually best handled in the application tier of your program,
sinnce you have good flexibility to rotate rows into columns.
--
HTH,
SriSamp
Email: srisamp@.gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp
<jwgoerlich@.gmail.com> wrote in message
news:1131967790.112616.168370@.g44g2000cwa.googlegroups.com...
> Hello,
> I would like some help on developing a SQL query.
> I have a Team table and a Person Table. For simplicity sake, lets say
> the Team has a key and team name. The Person has a person key, team
> key, and person name.
> I want to query for all team members, and store the results in a single
> column. So, the resulting view would have three columns: team key, team
> name, and a list of all people on the team.
> Any pointers or tips appreciated,
> J Wolfgang Goerlich
>

Monday, March 26, 2012

how to connect to multiple database?

Is it possible to connect to 3 database and execute a cross db query?

I usually use SqlConnection(connectionString) for a single connection

As I understand, an open SQLConnection will connect to a SQL instance rather than just a SQL database, which means you can perform query on all objects in all databases if you have sufficient permission, just like what you can do in Query Analyzer. Is this what you want? If yes, you can write your query using qualified object name:

select * from db1.dbo.tbl1 as t1 join db2.dbo.tbl2 as t2

on t1.id=t2.id

Wednesday, March 7, 2012

how to comment out a block of codes in SQL Query Analyzer?

Hello,
I know '--' can be used to comment out a single line. I tried /* and */ but
got the follow errors.
/*use master
go
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Server: Msg 113, Level 15, State 1, Line 1
Missing end comment mark '*/'.
Server: Msg 170, Level 15, State 1, Line 8
Line 8: Incorrect syntax near '*'.
Thanks,
Bing
bing wrote on Tue, 29 Nov 2005 09:02:15 -0800:

> Hello,
> I know '--' can be used to comment out a single line. I tried /* and */
> but got the follow errors.
> /*use master
> go
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
> Server: Msg 113, Level 15, State 1, Line 1
> Missing end comment mark '*/'.
> Server: Msg 170, Level 15, State 1, Line 8
> Line 8: Incorrect syntax near '*'.
> Thanks,
> Bing
The GO is being interpreted as a batch delimiter. Just add some additional
markers around the GO.
/*
use master
*/
go
/*
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Dan
|||"Daniel Crichton" wrote:

> bing wrote on Tue, 29 Nov 2005 09:02:15 -0800:
>
> The GO is being interpreted as a batch delimiter. Just add some additional
> markers around the GO.
> /*
> use master
> */
> go
> /*
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
>
Ah, ok, thanks much for the heads-up.
Bing

how to comment out a block of codes in SQL Query Analyzer?

Hello,
I know '--' can be used to comment out a single line. I tried /* and */ but
got the follow errors.
/*use master
go
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Server: Msg 113, Level 15, State 1, Line 1
Missing end comment mark '*/'.
Server: Msg 170, Level 15, State 1, Line 8
Line 8: Incorrect syntax near '*'.
Thanks,
Bingbing wrote on Tue, 29 Nov 2005 09:02:15 -0800:

> Hello,
> I know '--' can be used to comment out a single line. I tried /* and */
> but got the follow errors.
> /*use master
> go
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
> Server: Msg 113, Level 15, State 1, Line 1
> Missing end comment mark '*/'.
> Server: Msg 170, Level 15, State 1, Line 8
> Line 8: Incorrect syntax near '*'.
> Thanks,
> Bing
The GO is being interpreted as a batch delimiter. Just add some additional
markers around the GO.
/*
use master
*/
go
/*
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Dan|||"Daniel Crichton" wrote:

> bing wrote on Tue, 29 Nov 2005 09:02:15 -0800:
>
>
> The GO is being interpreted as a batch delimiter. Just add some additional
> markers around the GO.
> /*
> use master
> */
> go
> /*
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
>
Ah, ok, thanks much for the heads-up.
Bing

Friday, February 24, 2012

how to comment out a block of codes in SQL Query Analyzer?

Hello,
I know '--' can be used to comment out a single line. I tried /* and */ but
got the follow errors.
/*use master
go
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Server: Msg 113, Level 15, State 1, Line 1
Missing end comment mark '*/'.
Server: Msg 170, Level 15, State 1, Line 8
Line 8: Incorrect syntax near '*'.
Thanks,
Bingbing wrote on Tue, 29 Nov 2005 09:02:15 -0800:
> Hello,
> I know '--' can be used to comment out a single line. I tried /* and */
> but got the follow errors.
> /*use master
> go
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
> Server: Msg 113, Level 15, State 1, Line 1
> Missing end comment mark '*/'.
> Server: Msg 170, Level 15, State 1, Line 8
> Line 8: Incorrect syntax near '*'.
> Thanks,
> Bing
The GO is being interpreted as a batch delimiter. Just add some additional
markers around the GO.
/*
use master
*/
go
/*
exec sp_addlinkedsrvlogin
@.rmtsrvname = 'access',
@.useself = false,
@.locallogin = 'administrator',
@.rmtuser = 'admin',
@.rmtpassword = NULL
*/
Dan|||"Daniel Crichton" wrote:
> bing wrote on Tue, 29 Nov 2005 09:02:15 -0800:
> > Hello,
> >
> > I know '--' can be used to comment out a single line. I tried /* and */
> > but got the follow errors.
> >
> > /*use master
> > go
> >
> > exec sp_addlinkedsrvlogin
> > @.rmtsrvname = 'access',
> > @.useself = false,
> > @.locallogin = 'administrator',
> > @.rmtuser = 'admin',
> > @.rmtpassword = NULL
> > */
> >
> > Server: Msg 113, Level 15, State 1, Line 1
> > Missing end comment mark '*/'.
> > Server: Msg 170, Level 15, State 1, Line 8
> > Line 8: Incorrect syntax near '*'.
> >
> > Thanks,
> >
> > Bing
>
> The GO is being interpreted as a batch delimiter. Just add some additional
> markers around the GO.
> /*
> use master
> */
> go
> /*
> exec sp_addlinkedsrvlogin
> @.rmtsrvname = 'access',
> @.useself = false,
> @.locallogin = 'administrator',
> @.rmtuser = 'admin',
> @.rmtpassword = NULL
> */
>
Ah, ok, thanks much for the heads-up.
Bing

how to combine text data rows into single row?

Hi!!!!

Need some quick help on SQL.....DTS packages.

I’ve loaded data from text files into a table which is in the following format.....

Seq_No

Row_No

Data

1

1

ABC

2

2

DEF

3

3

GHI

4

4

JKL

5

1

MNO

6

2

PQR

7

3

STU

8

4

VWX

Every four lines correspond to one single logical record. So, all the data in every 4 rows have to be combined into one big string which’ll then be loaded into one col of another temporary table .....structure below.....

Record_No

Data

1

ABCDEFGHIJKL

2

MNOPQRSTUVWX

I’m looking for a way to achieve this WITHOUT using Cursors (as it’ll slow down performance)......

Any suggestions will be highly appreciated.

what data type is the Data column?|||

One way is to use the CLR Aggregate function for string concatenation shown in the BOL

http://msdn2.microsoft.com/en-us/library/ms254508.aspx

and then run a query like this

select ((Seq_No-1) / 4)+1 as Record_No, dbo.Concatenate(Data) as Data
into dest
from source
group by ((Seq_No-1) / 4)+1
go

select * from dest
go

|||

hi pramy,

please refer to this post

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=586833&SiteID=1

regards

|||

hi Derek,

thanks for ur reply. the data type is of varchar.

|||

pramy, you still need help on this issue? if not please mark an answer.

thanks,

derek

|||

hi all,

thanks for ur response.

Derek, i've got the solution for my problem and the query is as given below.

select 'data' = convert(varchar(100),(a.data)+''+(b.data)+''+(c.data)+''+(d.data))

from test_data a,test_data b,test_data c,test_data d

where ((b.seqno=a.seqno+1 and b.rowno=a.rowno+1)and(c.seqno=b.seqno+1 and c.rowno=b.rowno+1)and(d.seqno=c.seqno+1 and d.rowno=c.rowno+1))

how to combine text data rows into single row?

Hi!!!!

Need some quick help on SQL.....DTS packages.

I’ve loaded data from text files into a table which is in the following format.....

Seq_No

Row_No

Data

1

1

ABC

2

2

DEF

3

3

GHI

4

4

JKL

5

1

MNO

6

2

PQR

7

3

STU

8

4

VWX

Every four lines correspond to one single logical record. So, all the data in every 4 rows have to be combined into one big string which’ll then be loaded into one col of another temporary table .....structure below.....

Record_No

Data

1

ABCDEFGHIJKL

2

MNOPQRSTUVWX

I’m looking for a way to achieve this WITHOUT using Cursors (as it’ll slow down performance)......

Any suggestions will be highly appreciated.

what data type is the Data column?|||

One way is to use the CLR Aggregate function for string concatenation shown in the BOL

http://msdn2.microsoft.com/en-us/library/ms254508.aspx

and then run a query like this

select ((Seq_No-1) / 4)+1 as Record_No, dbo.Concatenate(Data) as Data
into dest
from source
group by ((Seq_No-1) / 4)+1
go

select * from dest
go

|||

hi pramy,

please refer to this post

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=586833&SiteID=1

regards

|||

hi Derek,

thanks for ur reply. the data type is of varchar.

|||

pramy, you still need help on this issue? if not please mark an answer.

thanks,

derek

|||

hi all,

thanks for ur response.

Derek, i've got the solution for my problem and the query is as given below.

select 'data' = convert(varchar(100),(a.data)+''+(b.data)+''+(c.data)+''+(d.data))

from test_data a,test_data b,test_data c,test_data d

where ((b.seqno=a.seqno+1 and b.rowno=a.rowno+1)and(c.seqno=b.seqno+1 and c.rowno=b.rowno+1)and(d.seqno=c.seqno+1 and d.rowno=c.rowno+1))

How to Combine Multiple Rows Data into single Record or String based on a common field.

Hellow Folks.

Here is the Original Data in my single SQL 2005 Table:

Department: Sells:

1 Meat

1 Rice

1 Orange

2 Orange

2 Apple

3 Pears

The Data I would like read separated by Semi-colon:

Department: Sells:

1 Meat;Rice;Orange

2 Orange;Apple

3 Pears

I would like to read my data via SP or VStudio 2005 Page . Any help will be appreciated. Thanks..

Hi,

you can use the following Function in SQL server:

USE NORTHWIND
GO

CREATE FUNCTION ProductList (@.CategoryIDINT)
RETURNSVARCHAR(1000)
AS
BEGIN
DECLARE @.ProductsVARCHAR(1000)

SELECT@.Products =COALESCE(@.Products +', ','') + ProductName
FROM Products
WHERE CategoryID = @.CategoryID
ORDER BY ProductNameASC

RETURN @.Products
END
GO

SELECTDISTINCT CategoryID, dbo.ProductList (CategoryID)AS ProductList
FROM Products
GO

 
and this is based on your table: 
 
USE NORTHWINDCS
GO

CREATE FUNCTION ProductList (@.CategoryIDINT)
RETURNSVARCHAR(1000)
AS
BEGIN
DECLARE @.ProductsVARCHAR(1000)

SELECT@.Products =COALESCE(@.Products +', ','') + sells
FROM table1
WHERE Department = @.CategoryID
ORDER BY sellsASC

RETURN @.Products
END
GO

SELECTDISTINCT Department, dbo.ProductList (department)AS ProductList
FROM table1
GO

thanks

|||

SharpGuy, your solution works. Thanks and have a great Thanksgiving...

How to combine different data regions in a single report?

Hi, all here,

I am trying to use report designer to create a single report with chart data region and table data region combined within the same report. Would anyone here please guide me how to work it out? Thanks a lot.

With best regards,

What do you mean by combined? You can put several data regions in a report and each can have their own datasource or share the same. If you want to have a chart data region inside a table data region, then I believe that cannot be done. If you could be a little more specific as to what you want to accomplish that would help to answer your question.|||Hi,Itzeld,thanks, got it done.