Showing posts with label tables. Show all posts
Showing posts with label tables. Show all posts

Friday, March 30, 2012

Please help me

i have 2 tables like yarn_fpdt_in and yarn_fpdt_out the yarn_fpdt_in contain barcode,pallet,qty and yarn_fpdt_out contain same like 1st table like following

SELECT * FROM YARN_FPDT_IN;

BarcodePalletGrossWtQty
702171132900
70717917757599
70718316752599
7071959752599

SELECT * FROM YARN_FPDT_out;

BarcodePalletGrossWtQty
702111132900
702123132400
20705611765725
2070653665620
20707713648603
2070815752599

and question is

please create one another table like yarn_fpdt_result and display the result like this

BarcodePalletGrossWtQty
7021331322200
20705611765725
2070653665620
20707713648603
2070815752599
70717917757599
70718316752599
7071959752599

ok

its very urgent plz help me

Quote:

Originally Posted by asvinalbert

i have 2 tables like yarn_fpdt_in and yarn_fpdt_out the yarn_fpdt_in contain barcode,pallet,qty and yarn_fpdt_out contain same like 1st table like following

SELECT * FROM YARN_FPDT_IN;

BarcodePalletGrossWtQty
702171132900
70717917757599
70718316752599
7071959752599

SELECT * FROM YARN_FPDT_out;

BarcodePalletGrossWtQty
702111132900
702123132400
20705611765725
2070653665620
20707713648603
2070815752599

and question is

please create one another table like yarn_fpdt_result and display the result like this

BarcodePalletGrossWtQty
7021331322200
20705611765725
2070653665620
20707713648603
2070815752599
70717917757599
70718316752599
7071959752599

ok

its very urgent plz help me


Use UNION

Select * from YARN_FPDT_IN
UNION
Select * from YARN_FPDT_out|||As you have posted a question in the Article section it is being moved to SQL Server Forum

MODERATOR

Wednesday, March 28, 2012

Please help in queries

Hi,

I have 5 tables in sql database, naming Book, Category, Subject, UserDownload, User.

In Book table, BookID, BookTitle, CategoryID

In Category table, CategoryID, CategoryName

In Subject table, SubjectID, SubjectName, CategoryID

In UserDownload table, UserID, BookID

In User table, UserID, UserName

I used Book to store information of books. Those books has many categories. In those categories, there is also some subjects.

When user downloads book, I update UserDownload table.

The result I want to get is, Top Ten Download Subject. How can I get? Please help me.

The way I approach this kind of query is to first list the columns I need to return. Then I start thinking about which tables I need to touch to get that data, and then I think about how the data is related. Something like this should work for you:

SELECT
Subject.SubjectID,
Subject.SubjectName,
TopDownloads.BookCount
FROM
Subject
INNER JOIN
Book ON Subject.CategoryID = Book.CategoryID
INNER JOIN
(SELECT TOP 10 BookID, COUNT(*) AS BookCount FROM UserDownload GROUP BY BookID ORDER BY COUNT(*) DESC) AS TopDownloads ON Book.BookID = TopDownloads.BookID

please help access/sql server conversion

I am new to the db world. I am trying to convert an Access 2000 database to SQL Server 2000. f/e has forms, reports, macros, modules, b/e has tables which the f/e file has linked to via link manager. The b/e is on a shared network drive. A dozen users, about 150 tables. The b/e file is appoaching 1Gb. The plan is to keep the Access f/e.

I have read the microsoft Q;s on Upsizing, DTS, Access Project vs Access database, Access sv SQL, etc. I am having diffculty understanding the best approach for my situation.

Looking for some expert guidance before I jump in.

Thanx

CFWhy do you need to migrate your data hauling operation from pickup trucks to 18 wheelers in the first place? Load? Speed? Safety?

How about - just for starters - a simple/non-radical/initial approach:
Keep everything the way it is except for actual data in Access tables that could go into SQL tables instead with Access tables linked to it. This will for instance overcome one of the biggest Access limits: 2 GB per "mdb".
(As you probably know, once over 2 GB - in 2000 & 2002/XP - Access could crash at any moment with data from it never to be seen again. )|||Thanks for your quick reply.

Speed is the main thing, and there have been multiple user contention problems leading to lockup. The site is upgrading everything for speed.

When you say "move the actual data only" What's the proper method - simplest, to move the data only, i.e., how do i create the SQL tables automatically/safely (150 tables), and then weeks/days later move the Access data to the new tables?

Thanks,

CF|||The real Client-Server solution would be "by the book" conversion of Access "mdb" into Access Project (mdp) as a front end and storing data with data processing in SQL S.
This of course is easier said than done, especially on live and often used db.

What is really easy (although not a real solution) is to first setup tables in SQL S., work out minor differences of data types between Access an SQL S., run SQL S. import wizard to populate the tables and then link to them from Access. For one thing it is a quick workaround for JET limit of 2 GB per mdb since linked tables do not take lot of room, for another is getting data into SQL S. to find out stress-free any conversion issues, like for instance often with date/time fields.

I had Access run like hell this primitive way on well indexed datasets of over 50 GB.sql

Monday, March 26, 2012

Please help - Transaction Log not shrinking!

Hi,
My production DB transaction log has grown to 25 GBs. (It was <8 Gbs
yesterday). DBCC Reindex was issued against all tables as part of
monthly DB maintenance. Since then I have performed a full DB backup,
have performed log backups, then performed log backup with truncate
only option, then reissued the DBCC Shrinkfile command and tried to
shrink the log file via SSMS - nothing happens. The transaction log
file is still over 25 GBs.
This is in SQL Server 2005. I've even changed the recovery model to
Simple, issued the DBCC Shrinkfile - no change, and then switched back
to FULL - still no change.
What am I missing here?First read about backup, and recovery model in Books Online. Then check out
http://www.karaszi.com/SQLServer/info_dont_shrink.asp.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<sqlQuest@.gmail.com> wrote in message news:1151589347.687402.206610@.x69g2000cwx.googlegroups.com...
> Hi,
> My production DB transaction log has grown to 25 GBs. (It was <8 Gbs
> yesterday). DBCC Reindex was issued against all tables as part of
> monthly DB maintenance. Since then I have performed a full DB backup,
> have performed log backups, then performed log backup with truncate
> only option, then reissued the DBCC Shrinkfile command and tried to
> shrink the log file via SSMS - nothing happens. The transaction log
> file is still over 25 GBs.
> This is in SQL Server 2005. I've even changed the recovery model to
> Simple, issued the DBCC Shrinkfile - no change, and then switched back
> to FULL - still no change.
> What am I missing here?
>|||Try this:
USE MASTER
BACKUP LOG YourDatabase WITH TRUNCATE_ONLY
GO
USE YourDatabase
DBCC SHRINKFILE (YourDatabase _log, 1000)
This should shrink the log file to 1GB
Ozcan
"Tibor Karaszi" wrote:
> First read about backup, and recovery model in Books Online. Then check out
> http://www.karaszi.com/SQLServer/info_dont_shrink.asp.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <sqlQuest@.gmail.com> wrote in message news:1151589347.687402.206610@.x69g2000cwx.googlegroups.com...
> > Hi,
> >
> > My production DB transaction log has grown to 25 GBs. (It was <8 Gbs
> > yesterday). DBCC Reindex was issued against all tables as part of
> > monthly DB maintenance. Since then I have performed a full DB backup,
> > have performed log backups, then performed log backup with truncate
> > only option, then reissued the DBCC Shrinkfile command and tried to
> > shrink the log file via SSMS - nothing happens. The transaction log
> > file is still over 25 GBs.
> >
> > This is in SQL Server 2005. I've even changed the recovery model to
> > Simple, issued the DBCC Shrinkfile - no change, and then switched back
> > to FULL - still no change.
> >
> > What am I missing here?
> >
>

Please help - Transaction Log not shrinking!

Hi,
My production DB transaction log has grown to 25 GBs. (It was <8 Gbs
yesterday). DBCC Reindex was issued against all tables as part of
monthly DB maintenance. Since then I have performed a full DB backup,
have performed log backups, then performed log backup with truncate
only option, then reissued the DBCC Shrinkfile command and tried to
shrink the log file via SSMS - nothing happens. The transaction log
file is still over 25 GBs.
This is in SQL Server 2005. I've even changed the recovery model to
Simple, issued the DBCC Shrinkfile - no change, and then switched back
to FULL - still no change.
What am I missing here?First read about backup, and recovery model in Books Online. Then check out
http://www.karaszi.com/SQLServer/info_dont_shrink.asp.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<sqlQuest@.gmail.com> wrote in message news:1151589347.687402.206610@.x69g2000cwx.googlegroups
.com...
> Hi,
> My production DB transaction log has grown to 25 GBs. (It was <8 Gbs
> yesterday). DBCC Reindex was issued against all tables as part of
> monthly DB maintenance. Since then I have performed a full DB backup,
> have performed log backups, then performed log backup with truncate
> only option, then reissued the DBCC Shrinkfile command and tried to
> shrink the log file via SSMS - nothing happens. The transaction log
> file is still over 25 GBs.
> This is in SQL Server 2005. I've even changed the recovery model to
> Simple, issued the DBCC Shrinkfile - no change, and then switched back
> to FULL - still no change.
> What am I missing here?
>|||First read about backup, and recovery model in Books Online. Then check out
http://www.karaszi.com/SQLServer/info_dont_shrink.asp.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<sqlQuest@.gmail.com> wrote in message news:1151589347.687402.206610@.x69g2000cwx.googlegroups
.com...
> Hi,
> My production DB transaction log has grown to 25 GBs. (It was <8 Gbs
> yesterday). DBCC Reindex was issued against all tables as part of
> monthly DB maintenance. Since then I have performed a full DB backup,
> have performed log backups, then performed log backup with truncate
> only option, then reissued the DBCC Shrinkfile command and tried to
> shrink the log file via SSMS - nothing happens. The transaction log
> file is still over 25 GBs.
> This is in SQL Server 2005. I've even changed the recovery model to
> Simple, issued the DBCC Shrinkfile - no change, and then switched back
> to FULL - still no change.
> What am I missing here?
>|||Try this:
USE MASTER
BACKUP LOG YourDatabase WITH TRUNCATE_ONLY
GO
USE YourDatabase
DBCC SHRINKFILE (YourDatabase _log, 1000)
This should shrink the log file to 1GB
Ozcan
"Tibor Karaszi" wrote:

> First read about backup, and recovery model in Books Online. Then check ou
t
> http://www.karaszi.com/SQLServer/info_dont_shrink.asp.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <sqlQuest@.gmail.com> wrote in message news:1151589347.687402.206610@.x69g20
00cwx.googlegroups.com...
>|||Try this:
USE MASTER
BACKUP LOG YourDatabase WITH TRUNCATE_ONLY
GO
USE YourDatabase
DBCC SHRINKFILE (YourDatabase _log, 1000)
This should shrink the log file to 1GB
Ozcan
"Tibor Karaszi" wrote:

> First read about backup, and recovery model in Books Online. Then check ou
t
> http://www.karaszi.com/SQLServer/info_dont_shrink.asp.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> <sqlQuest@.gmail.com> wrote in message news:1151589347.687402.206610@.x69g20
00cwx.googlegroups.com...
>sql

Please Help

We have turned repliaction off our server but we cannot
delete or modify any of our tables. Any hints ?
Thanks
J
http://www.nwsu.com/0974973602.html
|||Hi,
Suspect database may be due to below reasons.
1. MDF or LDF files may be used during the SQL Server service startup
2. LDF file might be corrupt or immediate power shutdown caused the LDF to
corrupt
3. MDF file - Page allocations issue
For the point 1.
Just Run sp_resetstatus <dbname> and restart SQL server service
For the point 2.
a. Start SQL Server in emergency mode
Setting the database status to emergency mode tells SQL Server to
skipautomatic recovery and lets you access the data.
To get your data, use this script:
Sp_configure "allow updates", 1
go
Reconfigure with override
GO
Update sysdatabases set status = 32768 where name = "BadDbName"
go
Sp_configure "allow updates", 0
go
Reconfigure with override
GO
You might be able to use bulk copy program (bcp), simple SELECT commands, or
use DTS to extract
your data while the database is in emergency mode. After this database will
be usable with out transaction log. AFter this
create a new database and use DTS to transfer objects and data
For point 3. Very critical error , try executing DBCC CHECKDB with
REPAIR_REBUILD
option. If the problem is not rectified try with restore from Backup or
contact Microsoft support.
Thanks
Hari
SQL Server MVP
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:A54AC7E4-535E-4083-A710-AC1205F1AB85@.microsoft.com...
> Hello,
> I do not see any data in my database through Enterprise manage. And its
> status became "suspect", what doe that mean? How can I resolve this
> problem?
> Thanks,
>
sql

Friday, March 23, 2012

Please Help

We have turned repliaction off our server but we cannot
delete or modify any of our tables. Any hints ?
Thanks
Jhttp://www.nwsu.com/0974973602.html|||Hi,
Suspect database may be due to below reasons.
1. MDF or LDF files may be used during the SQL Server service startup
2. LDF file might be corrupt or immediate power shutdown caused the LDF to
corrupt
3. MDF file - Page allocations issue
For the point 1.
Just Run sp_resetstatus <dbname> and restart SQL server service
For the point 2.
a. Start SQL Server in emergency mode
Setting the database status to emergency mode tells SQL Server to
skipautomatic recovery and lets you access the data.
To get your data, use this script:
Sp_configure "allow updates", 1
go
Reconfigure with override
GO
Update sysdatabases set status = 32768 where name = "BadDbName"
go
Sp_configure "allow updates", 0
go
Reconfigure with override
GO
You might be able to use bulk copy program (bcp), simple SELECT commands, or
use DTS to extract
your data while the database is in emergency mode. After this database will
be usable with out transaction log. AFter this
create a new database and use DTS to transfer objects and data
For point 3. Very critical error , try executing DBCC CHECKDB with
REPAIR_REBUILD
option. If the problem is not rectified try with restore from Backup or
contact Microsoft support.
Thanks
Hari
SQL Server MVP
"JIM.H." <JIMH@.discussions.microsoft.com> wrote in message
news:A54AC7E4-535E-4083-A710-AC1205F1AB85@.microsoft.com...
> Hello,
> I do not see any data in my database through Enterprise manage. And its
> status became "suspect", what doe that mean? How can I resolve this
> problem?
> Thanks,
>

Please Help

We have turned repliaction off our server but we cannot
delete or modify any of our tables. Any hints ?
Thanks
Jhttp://www.nwsu.com/0974973602.html

please check

There are 2 tables -
say table 1 - child table - say child
table 2 - parent table - say parent
Assume that each child only resides on a single parent and each parent
may contain multiple children....
Can we write a query for finding how many children are on each and
every parent...?Why are you starting a new thread for the same question?
<chump1708@.yahoo.com> wrote in message
news:1134656162.207875.44300@.o13g2000cwo.googlegroups.com...
> There are 2 tables -
> say table 1 - child table - say child
> table 2 - parent table - say parent
>
> Assume that each child only resides on a single parent and each parent
> may contain multiple children....
> Can we write a query for finding how many children are on each and
> every parent...?
>|||well...thats bcoz the earlier question was confusing and typed wrongly..|||chump1708@.yahoo.com wrote:

> well...thats bcoz the earlier question was confusing and typed
> wrongly..
Did you try my query?
I don't quite understand why the others are giving links to handle this
with self-referenced tables. You said you have 2 tables: one with
children and and with parents. So IMHO there is no need for that.
HTH,
Stijn Verrept.|||Dear Stijin,
select cid, (select count(*) from childTable where gid = cid) as
ChildCount from parentTable
I got with this...why do u use 'as' word ?
and ChildCount - ? - what do u mean how 2 implement this?
All i have is
2 tables
table1 - child ('gid') and
table 2 - parent ('cid'). Each child only resides on a single
parent and each parent may contain multiple children. How do would you
find how many children are on each and every parent?
CAN U PLEASE REWRITE THE CODE>>>>>>|||chump1708@.yahoo.com wrote:

> I got with this...why do u use 'as' word ?
> and ChildCount - ? - what do u mean how 2 implement this?
> All i have is
> 2 tables
> table1 - child ('gid') and
> table 2 - parent ('cid'). Each child only resides on a single
> parent and each parent may contain multiple children. How do would you
> find how many children are on each and every parent?
> CAN U PLEASE REWRITE THE CODE>>>>>>
No need to shout!
It is completely impossible for us to rewrite correct code for you if
you do not provide us with the DLL: check this before asking a
question: www.aspfaq.com/5006
AS is to give the result column a name.
Kind regards,
Stijn Verrept.|||Seriously, have you any experience with T-SQL?
The AS keyword precedes the column alias to be used as the name of the
column in the result set.
ML
http://milambda.blogspot.com/|||select parent, count(1)
from parent p
join child c on p.parentId = c.parentId
group by parent
<chump1708@.yahoo.com> wrote in message
news:1134656162.207875.44300@.o13g2000cwo.googlegroups.com...
> There are 2 tables -
> say table 1 - child table - say child
> table 2 - parent table - say parent
>
> Assume that each child only resides on a single parent and each parent
> may contain multiple children....
> Can we write a query for finding how many children are on each and
> every parent...?
>|||if you want the parent with zero children do the following
select parent, count(1)
from parent p
left join child c on p.parentId = c.parentId
group by parent
"JI" <jidawgs@.hotmail.com> wrote in message
news:%23bFvOhaAGHA.208@.tk2msftngp13.phx.gbl...
> select parent, count(1)
> from parent p
> join child c on p.parentId = c.parentId
> group by parent
> <chump1708@.yahoo.com> wrote in message
> news:1134656162.207875.44300@.o13g2000cwo.googlegroups.com...
>sql

please check

There are 2 tables -
say table 1 - child table - say child
table 2 - parent table - say parent
Assume that each child only resides on a single parent and each parent
may contain multiple children....
Can we write a query for finding how many children are on each and
every parent...?How many times?
ML
http://milambda.blogspot.com/

Tuesday, March 20, 2012

placing system table filegroup and Log files on same drive

Is it better to create a seperate filegroup for all user tables ? And if so
should all the system tables that belong to the Primary filegroup reside on
the same drive with the log file . I am using SQL 2000. Which system tables
get hit the most daily for any inserts,updates and deletes that may be
occuring on the server
ThanksDepends on the disk configuration.
I believe it is generally recommended to separate the log file from any data
files, i.e., separate physical disks... however, if you have a multiple
channel controller, with high thoroughput on each channel, you may be able
to get by w/ having the log and the data on the same logical disk.
I believe that all system tables must reside in PRIMARY, I'd have to verify.
If that is true, it doesn't matter what system tables get inserts, updates,
deletes. However, you are taking away some fault tolerance if you put the
system tables and the log files on the same physical disk.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:%23AKD5sEXDHA.1872@.TK2MSFTNGP12.phx.gbl...
> Is it better to create a seperate filegroup for all user tables ? And if
so
> should all the system tables that belong to the Primary filegroup reside
on
> the same drive with the log file . I am using SQL 2000. Which system
tables
> get hit the most daily for any inserts,updates and deletes that may be
> occuring on the server
> Thanks
>|||You also generally want log files on RAID 1 or 10 as they are continuously
sequentially writing.
Thanks,
Greg H
"Martin Schmid" <martinschmid@.sbcglobal.net.nospam> wrote in message
news:eoDKm2EXDHA.2212@.TK2MSFTNGP09.phx.gbl...
> Depends on the disk configuration.
> I believe it is generally recommended to separate the log file from any
data
> files, i.e., separate physical disks... however, if you have a multiple
> channel controller, with high thoroughput on each channel, you may be able
> to get by w/ having the log and the data on the same logical disk.
> I believe that all system tables must reside in PRIMARY, I'd have to
verify.
> If that is true, it doesn't matter what system tables get inserts,
updates,
> deletes. However, you are taking away some fault tolerance if you put the
> system tables and the log files on the same physical disk.
>
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:%23AKD5sEXDHA.1872@.TK2MSFTNGP12.phx.gbl...
> > Is it better to create a seperate filegroup for all user tables ? And if
> so
> > should all the system tables that belong to the Primary filegroup reside
> on
> > the same drive with the log file . I am using SQL 2000. Which system
> tables
> > get hit the most daily for any inserts,updates and deletes that may be
> > occuring on the server
> >
> > Thanks
> >
> >
>|||Hassan
If you are using SQL Server 7, it is a good idea to put
your system files in a seperate filegroup. If you get a
corrupted user table, if your system tables are in a
seperate filegroup you can still perform a transaction log
backup prior to invoking DR (If you have DR of course). If
they are in the same filegroup you may not be able to.
This is no longer an issue in 2000.
Hope this helps
John

Placing of Indexes on seperate data file

Is it good practise to put large nonclustered of frequently queried tables on a seperate datafile to the actual table? I.e. a file using a different disk/s.
Thanks
www.SQLporn.co.uk
This was the best case, especially in DB2. I would suggest that in SQL Server it is generally not the case, especially if you choose your storage system carefully. (such as raid 1+0)
|||It's not a good idea to segregate data based only on access frequency. This
will tend to create an unbalanced workload on your i/o subsystem with
relatively few disks doing the lion's share of the work. It's better to
separate data based on sequential, random or mixed access. This will
maximize sequential throughput because random requests won't interfere with
sequential scanning.
Logs are always accessed sequentially and these should be placed on
dedicated drives. Indexes and data objects with mostly random access
patterns and objects with mostly sequential access should be segregated onto
different disks/arrays. The remaining data can be placed in a 'mixed'
filegroup.
However, unless you have predictable data access patterns, it's best to
distribute files evenly over all of your disks rather than micro-manage
object placement. In my experience, this usually provides the best overall
database performance. Run performance tests with a representative
application workload if you feel inclined to play with specialized
filegroups.
Hope this helps.
Dan Guzman
SQL Server MVP
"Rstubbs" <anonymous@.discussions.microsoft.com> wrote in message
news:7DBF9EE7-D750-4E1E-B6A3-3A7E9D28F9C8@.microsoft.com...
> Is it good practise to put large nonclustered of frequently queried tables
on a seperate datafile to the actual table? I.e. a file using a different
disk/s.
> Thanks
> www.SQLporn.co.uk

Placing of Indexes on seperate data file

Is it good practise to put large nonclustered of frequently queried tables on a seperate datafile to the actual table? I.e. a file using a different disk/s
Thank
www.SQLporn.co.ukIt's not a good idea to segregate data based only on access frequency. This
will tend to create an unbalanced workload on your i/o subsystem with
relatively few disks doing the lion's share of the work. It's better to
separate data based on sequential, random or mixed access. This will
maximize sequential throughput because random requests won't interfere with
sequential scanning.
Logs are always accessed sequentially and these should be placed on
dedicated drives. Indexes and data objects with mostly random access
patterns and objects with mostly sequential access should be segregated onto
different disks/arrays. The remaining data can be placed in a 'mixed'
filegroup.
However, unless you have predictable data access patterns, it's best to
distribute files evenly over all of your disks rather than micro-manage
object placement. In my experience, this usually provides the best overall
database performance. Run performance tests with a representative
application workload if you feel inclined to play with specialized
filegroups.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Rstubbs" <anonymous@.discussions.microsoft.com> wrote in message
news:7DBF9EE7-D750-4E1E-B6A3-3A7E9D28F9C8@.microsoft.com...
> Is it good practise to put large nonclustered of frequently queried tables
on a seperate datafile to the actual table? I.e. a file using a different
disk/s.
> Thanks
> www.SQLporn.co.uk

Placing of Indexes on seperate data file

Is it good practise to put large nonclustered of frequently queried tables o
n a seperate datafile to the actual table? I.e. a file using a different dis
k/s.
Thanks
www.SQLporn.co.ukThis was the best case, especially in DB2. I would suggest that in SQL Serv
er it is generally not the case, especially if you choose your storage syste
m carefully. (such as raid 1+0)|||It's not a good idea to segregate data based only on access frequency. This
will tend to create an unbalanced workload on your i/o subsystem with
relatively few disks doing the lion's share of the work. It's better to
separate data based on sequential, random or mixed access. This will
maximize sequential throughput because random requests won't interfere with
sequential scanning.
Logs are always accessed sequentially and these should be placed on
dedicated drives. Indexes and data objects with mostly random access
patterns and objects with mostly sequential access should be segregated onto
different disks/arrays. The remaining data can be placed in a 'mixed'
filegroup.
However, unless you have predictable data access patterns, it's best to
distribute files evenly over all of your disks rather than micro-manage
object placement. In my experience, this usually provides the best overall
database performance. Run performance tests with a representative
application workload if you feel inclined to play with specialized
filegroups.
Hope this helps.
Dan Guzman
SQL Server MVP
"Rstubbs" <anonymous@.discussions.microsoft.com> wrote in message
news:7DBF9EE7-D750-4E1E-B6A3-3A7E9D28F9C8@.microsoft.com...
> Is it good practise to put large nonclustered of frequently queried tables
on a seperate datafile to the actual table? I.e. a file using a different
disk/s.
> Thanks
> www.SQLporn.co.uk

Monday, March 12, 2012

placing existing table on a different filegroup

Hi ,
Is there any commands to place existing tables to a new file group besides
using the EM as below ?
How to place an existing table on a different filegroup (Enterprise Manager)
To place an existing table on a different filegroup
Expand a server group, and then expand a server.
Expand Databases, expand the database in which the table belongs, and then
click Tables.
In the details pane, right-click the table, and then click Design Table.
Right-click any column, and then click Properties.
On the Tables tab, in the Table Filegroup list, select the filegroup on whic
h
to place the table.
Optionally, in the Text Filegroup list, select a filegroup on which to place
any text, image, and ntext columns.
appreciate any advise
tks & rdgs
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200605/1You can (re)create a clustered index for the table; the data will always
move to the FG that the clustered index is built on
HTH
Kalen Delaney, SQL Server MVP
www.solidqualitylearning.com
"maxzsim via webservertalk.com" <u14644@.uwe> wrote in message
news:5ff96f8c4fdba@.uwe...
> Hi ,
> Is there any commands to place existing tables to a new file group besides
> using the EM as below ?
> How to place an existing table on a different filegroup (Enterprise
> Manager)
> To place an existing table on a different filegroup
> Expand a server group, and then expand a server.
> Expand Databases, expand the database in which the table belongs, and then
> click Tables.
> In the details pane, right-click the table, and then click Design Table.
> Right-click any column, and then click Properties.
> On the Tables tab, in the Table Filegroup list, select the filegroup on
> which
> to place the table.
> Optionally, in the Text Filegroup list, select a filegroup on which to
> place
> any text, image, and ntext columns.
> appreciate any advise
> tks & rdgs
> --
> Message posted via webservertalk.com
> http://www.webservertalk.com/Uwe/Forum...amming/200605/1|||Hi ,
Another is for the Text FileGroup : i seem not able to change it to the new
filegroup it keeps turning back to the PRIMARY FileGroup even though i have
changed to a new filegorup and saved it
any possibly reason ?
tks & rdgs
maxzsim wrote:
>Hi ,
> Is there any commands to place existing tables to a new file group besides
>using the EM as below ?
>How to place an existing table on a different filegroup (Enterprise Manager
)
>To place an existing table on a different filegroup
>Expand a server group, and then expand a server.
>Expand Databases, expand the database in which the table belongs, and then
>click Tables.
>In the details pane, right-click the table, and then click Design Table.
>Right-click any column, and then click Properties.
>On the Tables tab, in the Table Filegroup list, select the filegroup on whi
ch
>to place the table.
>Optionally, in the Text Filegroup list, select a filegroup on which to plac
e
>any text, image, and ntext columns.
>appreciate any advise
>tks & rdgs
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200605/1|||It is interesting to see on Profiler what Enterprise Manager is doing when
you follow that procedure. Among other commands is doing
-- to move mytable to myfilegroup
create table tmp_mytable ( ... ) on myfilegroup
insert into tmp_mytable (select ... from mytable)
drop table mytable
sp_rename tmp_mytable mytable
Ben Nevarez, MCDBA, OCP
Database Administrator
"maxzsim via webservertalk.com" wrote:

> Hi ,
> Is there any commands to place existing tables to a new file group beside
s
> using the EM as below ?
> How to place an existing table on a different filegroup (Enterprise Manage
r)
> To place an existing table on a different filegroup
> Expand a server group, and then expand a server.
> Expand Databases, expand the database in which the table belongs, and then
> click Tables.
> In the details pane, right-click the table, and then click Design Table.
> Right-click any column, and then click Properties.
> On the Tables tab, in the Table Filegroup list, select the filegroup on wh
ich
> to place the table.
> Optionally, in the Text Filegroup list, select a filegroup on which to pla
ce
> any text, image, and ntext columns.
> appreciate any advise
> tks & rdgs
> --
> Message posted via webservertalk.com
> http://www.webservertalk.com/Uwe/Forum...amming/200605/1
>|||tks
Kalen Delaney wrote:
>You can (re)create a clustered index for the table; the data will always
>move to the FG that the clustered index is built on
>
>[quoted text clipped - 20 lines]
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Forum...amming/200605/1|||hi ,
this is what i got from the profiler using the standard i.e no inclsion of
columns or new processes or any filter:
use [GL53_03_Bkup]
set implicit_transactions on SET TEXTSIZE 2147483647
sp_MStablechecks N'dbo.GL030106'
IF @.@.TRANCOUNT > 0 COMMIT TRAN
set implicit_transactions off SET TEXTSIZE 64512
use [GL53_03_Bkup]
select s1 = o.name, s2 = user_name(o.uid),o.crdate,o.id, N'SystemObj' = (cas
e
when (OBJECTPROPERTY(o.id, N'IsMSShipped')=1) then 1 else OBJECTPROPERTY(o.i
d,
N'IsSystemTable') end), o.category, 0, ObjectProperty(o.id,
N'TableHasActiveFulltextIndex'), ObjectProperty(o.id,
N'TableFulltextCatalogId'), N'FakeTable' = (case when (OBJECTPROPERTY(o.id,
N'tableisfake')=1) then 1 else 0 end), (case when (OBJECTPROPERTY(o.i
d,
N'IsQuotedIdentOn')=1) then 1 else 0 end), (case when (OBJECTPROPERTY(o.id,
N'IsAnsiNullsOn')=1) then 1 else 0 end) from dbo.sysobjects o, dbo.
sysindexes i where OBJECTPROPERTY(o.id, N'IsTable') = 1 and i.id = o.id and
i.
indid < 2 and o.name not like N'#%' and o.id = object_id(N'[dbo].[GL030106]
') order by s1, s2
SELECT N'Testing Connection...'
what can i actually make out of this ? or what other events i should be
included to see such changes ?
The table : Gl030106's original "Text FileGroup" is "PRIMARY" when i tried t
o
change it to my own FG : TEST2 and saved it goes back to PRIMARY
tks & rdgs
Ben Nevarez wrote:
>It is interesting to see on Profiler what Enterprise Manager is doing when
>you follow that procedure. Among other commands is doing
>-- to move mytable to myfilegroup
>create table tmp_mytable ( ... ) on myfilegroup
>insert into tmp_mytable (select ... from mytable)
>drop table mytable
>sp_rename tmp_mytable mytable
>Ben Nevarez, MCDBA, OCP
>Database Administrator
>
>[quoted text clipped - 17 lines]
Message posted via http://www.webservertalk.com

Placing a table on multiple files

I have very two big tables and I want to put them on
multiple files within a file group. I know that a
filegroup can have multiple files,but I am not sure how
exactly the table spans across the files.
Is there any way that I can put the table on multiple
files?
Please provide me some examples.
Thanks for help.
RajIf you have multiple files in a filegroup, and create the table on that =filegroup then the table will automatically be allocated space across =the two files. This space will be taken as the table grows, space is =taken in the same ratio as the currently available free space within the =file.
What would be interesting is:
What do you mean by big?
What are you looking to achieve?
Are the two(or more) files all physically on different drives or merely =separate files on the same array.
The benefits you may see (or not see) are all affected by the above.
Mike John
"Raj" <vmresumes@.yahoo.com> wrote in message =news:909a01c345b3$0b4f6140$a401280a@.phx.gbl...
> I have very two big tables and I want to put them on > multiple files within a file group. I know that a > filegroup can have multiple files,but I am not sure how > exactly the table spans across the files.
> > Is there any way that I can put the table on multiple > files?
> > Please provide me some examples.
> > Thanks for help.
> > Raj|||Thanks for the response.
We have 2 fact tables each 10 GB. To gain the performance and aslo easy
management of files, I wanted to put on different physical disks.
Raj.
"Mike John" <Mike.John@.knowledgepool.com> wrote in message
news:OuDOvSdRDHA.2144@.TK2MSFTNGP11.phx.gbl...
If you have multiple files in a filegroup, and create the table on that
filegroup then the table will automatically be allocated space across the
two files. This space will be taken as the table grows, space is taken in
the same ratio as the currently available free space within the file.
What would be interesting is:
What do you mean by big?
What are you looking to achieve?
Are the two(or more) files all physically on different drives or merely
separate files on the same array.
The benefits you may see (or not see) are all affected by the above.
Mike John
"Raj" <vmresumes@.yahoo.com> wrote in message
news:909a01c345b3$0b4f6140$a401280a@.phx.gbl...
> I have very two big tables and I want to put them on
> multiple files within a file group. I know that a
> filegroup can have multiple files,but I am not sure how
> exactly the table spans across the files.
> Is there any way that I can put the table on multiple
> files?
> Please provide me some examples.
> Thanks for help.
> Raj|||Sounds very sensible then - sorry for the questions but you often get =people worrying about a huge (2Gb) table and then creating multiple =filegroups on the same raid 5 array, which all gets a bit pointless!
Mike
"Vish" <mocherla_v@.hotmail.com> wrote in message =news:eHjqdPeRDHA.2480@.tk2msftngp13.phx.gbl...
> Thanks for the response.
> > We have 2 fact tables each 10 GB. To gain the performance and aslo =easy
> management of files, I wanted to put on different physical disks.
> > Raj.
> > "Mike John" <Mike.John@.knowledgepool.com> wrote in message
> news:OuDOvSdRDHA.2144@.TK2MSFTNGP11.phx.gbl...
> If you have multiple files in a filegroup, and create the table on =that
> filegroup then the table will automatically be allocated space across =the
> two files. This space will be taken as the table grows, space is taken =in
> the same ratio as the currently available free space within the file.
> > What would be interesting is:
> > What do you mean by big?
> What are you looking to achieve?
> Are the two(or more) files all physically on different drives or =merely
> separate files on the same array.
> > The benefits you may see (or not see) are all affected by the above.
> > Mike John
> > "Raj" <vmresumes@.yahoo.com> wrote in message
> news:909a01c345b3$0b4f6140$a401280a@.phx.gbl...
> > I have very two big tables and I want to put them on
> > multiple files within a file group. I know that a
> > filegroup can have multiple files,but I am not sure how
> > exactly the table spans across the files.
> >
> > Is there any way that I can put the table on multiple
> > files?
> >
> > Please provide me some examples.
> >
> > Thanks for help.
> >
> > Raj
> > >=20

Placement of sys.conversation_endpoints and sys.transmission_queue

Is there any thought going into moving these two tables to a file group that we can control? Putting this in Primary with the rest of my system tables is quite problematic, and hinders my ability to manage space usage on my files. Traditionally, we didn't have to consider a primary file group that could grow to large proportions, but now with these two tables it can. If a large volume of messages gets sent through and the system can't keep up, then these tables and my primary file group will grow sometimes enormously.

There are no plans to support this in the near future.

Rushi

|||

Ouch! This will be real painful, as whenever messages queue up it chews up a large amount of space. I would think that we are not too disimilar from other high transaction systems, and really don't want our primary file groups to fill up with anything other than schema definition and not require a large amount of space. This may be something important to consider, as it requires us, your customers, to plan in a completely different way than we have had to previously.

Thanks!

|||

You can submit this feedback here:

http://connect.microsoft.com/SQLServer

Rushi

|||

I agree and have raised a suggestion on connect.

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=249443

|||

The connect item has been closed

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=249443

but no comment on why it has been closed.

|||Operator error, the issue should be still active.|||Thought as much, any view on a resolution?

Placement of sys.conversation_endpoints and sys.transmission_queue

Is there any thought going into moving these two tables to a file group that we can control? Putting this in Primary with the rest of my system tables is quite problematic, and hinders my ability to manage space usage on my files. Traditionally, we didn't have to consider a primary file group that could grow to large proportions, but now with these two tables it can. If a large volume of messages gets sent through and the system can't keep up, then these tables and my primary file group will grow sometimes enormously.

There are no plans to support this in the near future.

Rushi

|||

Ouch! This will be real painful, as whenever messages queue up it chews up a large amount of space. I would think that we are not too disimilar from other high transaction systems, and really don't want our primary file groups to fill up with anything other than schema definition and not require a large amount of space. This may be something important to consider, as it requires us, your customers, to plan in a completely different way than we have had to previously.

Thanks!

|||

You can submit this feedback here:

http://connect.microsoft.com/SQLServer

Rushi

|||

I agree and have raised a suggestion on connect.

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=249443

|||

The connect item has been closed

https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=249443

but no comment on why it has been closed.

|||Operator error, the issue should be still active.|||Thought as much, any view on a resolution?

placeholder for uniqueidentifier

Hi,
I need help with a SQL SELECT statement. I am using a UNION to merge four
tables together. For the tables that did not include a particular field, I
have used a placeholder of 'N/A' in the SELECT statement as follows:
SELECT organizationid, organization_name, businessunitid,
business_unit_name, subdivision_id, subdivision_name, lot_no, plan_number,
plan_name, current_retail_price, current_expiration_date,
plan_availability_pricing_id, plan_id
FROM hb_view_lot_plan
UNION
SELECT organizationid, organization_name, businessunitid,
business_unit_name, subdivision_id, subdivision_name, 'N/A', plan_number,
plan_name, current_retail_price, current_expiration_date,
plan_availability_pricing_id, plan_id
FROM hb_view_subdivision_plan
UNION
SELECT organizationid, organization_name, businessunitid,
business_unit_name, 'N/A', 'N/A', 'N/A', plan_number, plan_name,
current_retail_price, current_expiration_date, plan_availability_pricing_id,
plan_id
FROM hb_view_business_unit_plan
UNION
SELECT organizationid, organization_name, businessunitid, 'N/A', 'N/A',
'N/A', 'N/A', plan_number, plan_name, current_retail_price,
current_expiration_date, plan_availability_pricing_id, plan_id
FROM hb_view_organization_plan
I am having a problem with using the 'N/A' placeholder in lieu of a
uniqueidentifier. It works for varchar field types but apparently not
uniqueidentifier type fields. I receive the error message "error converting
from character string into uniqueidentifier". Thanks for your help.
DonYou could cast the top uniqueidentifier to a varchar(36) and it will work.
It seems a bit wierd though, because are you going to display the guid to
the user? Pretty hideous if you are.
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
<dbj> wrote in message news:uwbfXluPFHA.2136@.TK2MSFTNGP14.phx.gbl...
> Hi,
> I need help with a SQL SELECT statement. I am using a UNION to merge four
> tables together. For the tables that did not include a particular field,
> I have used a placeholder of 'N/A' in the SELECT statement as follows:
>
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, subdivision_id, subdivision_name, lot_no, plan_number,
> plan_name, current_retail_price, current_expiration_date,
> plan_availability_pricing_id, plan_id
> FROM hb_view_lot_plan
> UNION
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, subdivision_id, subdivision_name, 'N/A', plan_number,
> plan_name, current_retail_price, current_expiration_date,
> plan_availability_pricing_id, plan_id
> FROM hb_view_subdivision_plan
> UNION
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, 'N/A', 'N/A', 'N/A', plan_number, plan_name,
> current_retail_price, current_expiration_date,
> plan_availability_pricing_id, plan_id
> FROM hb_view_business_unit_plan
> UNION
> SELECT organizationid, organization_name, businessunitid, 'N/A',
> 'N/A', 'N/A', 'N/A', plan_number, plan_name, current_retail_price,
> current_expiration_date, plan_availability_pricing_id, plan_id
> FROM hb_view_organization_plan
>
> I am having a problem with using the 'N/A' placeholder in lieu of a
> uniqueidentifier. It works for varchar field types but apparently not
> uniqueidentifier type fields. I receive the error message "error
> converting from character string into uniqueidentifier". Thanks for your
> help.
>
> Don
>
>|||When you use union, first query defines column data types for all other
queries.
So, the problem is (probably, you did not provide DDl, so I cannot tell for
sure) in 3th and/or 4th query, where you set 'N/A' for subdivision_id which
can be of GUID data type.
Solution can be to replace 'N/A' with "empty" guid
'{00000000-0000-0000-0000-000000000000}' or with null.
Regards,
Marko Simic
"dbj" wrote:

> Hi,
> I need help with a SQL SELECT statement. I am using a UNION to merge four
> tables together. For the tables that did not include a particular field,
I
> have used a placeholder of 'N/A' in the SELECT statement as follows:
>
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, subdivision_id, subdivision_name, lot_no, plan_number,
> plan_name, current_retail_price, current_expiration_date,
> plan_availability_pricing_id, plan_id
> FROM hb_view_lot_plan
> UNION
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, subdivision_id, subdivision_name, 'N/A', plan_number,
> plan_name, current_retail_price, current_expiration_date,
> plan_availability_pricing_id, plan_id
> FROM hb_view_subdivision_plan
> UNION
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, 'N/A', 'N/A', 'N/A', plan_number, plan_name,
> current_retail_price, current_expiration_date, plan_availability_pricing_i
d,
> plan_id
> FROM hb_view_business_unit_plan
> UNION
> SELECT organizationid, organization_name, businessunitid, 'N/A', 'N/A'
,
> 'N/A', 'N/A', plan_number, plan_name, current_retail_price,
> current_expiration_date, plan_availability_pricing_id, plan_id
> FROM hb_view_organization_plan
>
> I am having a problem with using the 'N/A' placeholder in lieu of a
> uniqueidentifier. It works for varchar field types but apparently not
> uniqueidentifier type fields. I receive the error message "error converti
ng
> from character string into uniqueidentifier". Thanks for your help.
>
> Don
>
>
>|||Sorry I forgot to write the most important part :)
SQL try to convert 'N/A' to uniqueidentifier data type which is not
possible. you may try this to see what will happen:
select newid()
union
select 'N/A'
Regards,
Marko Simic
"dbj" wrote:

> Hi,
> I need help with a SQL SELECT statement. I am using a UNION to merge four
> tables together. For the tables that did not include a particular field,
I
> have used a placeholder of 'N/A' in the SELECT statement as follows:
>
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, subdivision_id, subdivision_name, lot_no, plan_number,
> plan_name, current_retail_price, current_expiration_date,
> plan_availability_pricing_id, plan_id
> FROM hb_view_lot_plan
> UNION
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, subdivision_id, subdivision_name, 'N/A', plan_number,
> plan_name, current_retail_price, current_expiration_date,
> plan_availability_pricing_id, plan_id
> FROM hb_view_subdivision_plan
> UNION
> SELECT organizationid, organization_name, businessunitid,
> business_unit_name, 'N/A', 'N/A', 'N/A', plan_number, plan_name,
> current_retail_price, current_expiration_date, plan_availability_pricing_i
d,
> plan_id
> FROM hb_view_business_unit_plan
> UNION
> SELECT organizationid, organization_name, businessunitid, 'N/A', 'N/A'
,
> 'N/A', 'N/A', plan_number, plan_name, current_retail_price,
> current_expiration_date, plan_availability_pricing_id, plan_id
> FROM hb_view_organization_plan
>
> I am having a problem with using the 'N/A' placeholder in lieu of a
> uniqueidentifier. It works for varchar field types but apparently not
> uniqueidentifier type fields. I receive the error message "error converti
ng
> from character string into uniqueidentifier". Thanks for your help.
>
> Don
>
>
>|||Oops, no it won't (d'oh!) you will have to cast them all to char:
select cast( 'na' as varchar(36))
union
select cast(newId() as varchar(36))
Sorry,
----
Louis Davidson - drsql@.hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Blog - http://spaces.msn.com/members/drsql/
Note: Please reply to the newsgroups only unless you are interested in
consulting services. All other replies may be ignored :)
"Louis Davidson" <dr_dontspamme_sql@.hotmail.com> wrote in message
news:u%238on1uPFHA.532@.TK2MSFTNGP09.phx.gbl...
> You could cast the top uniqueidentifier to a varchar(36) and it will work.
> It seems a bit wierd though, because are you going to display the guid to
> the user? Pretty hideous if you are.
> --
> ----
--
> Louis Davidson - drsql@.hotmail.com
> SQL Server MVP
> Compass Technology Management - www.compass.net
> Pro SQL Server 2000 Database Design -
> http://www.apress.com/book/bookDisplay.html?bID=266
> Blog - http://spaces.msn.com/members/drsql/
> Note: Please reply to the newsgroups only unless you are interested in
> consulting services. All other replies may be ignored :)
> <dbj> wrote in message news:uwbfXluPFHA.2136@.TK2MSFTNGP14.phx.gbl...
>|||Marko,
Thank you very much. Your answer worked on the first try.
Don
"Simic Marko" <SimicMarko@.discussions.microsoft.com> wrote in message
news:CA618990-5DFD-4753-B3CC-13FA859F136C@.microsoft.com...
> When you use union, first query defines column data types for all other
> queries.
> So, the problem is (probably, you did not provide DDl, so I cannot tell
> for
> sure) in 3th and/or 4th query, where you set 'N/A' for subdivision_id
> which
> can be of GUID data type.
> Solution can be to replace 'N/A' with "empty" guid
> '{00000000-0000-0000-0000-000000000000}' or with null.
> Regards,
> Marko Simic
> "dbj" wrote:
>

Place results in Colmn rather than rows

I have a few tables that i need to run a query on and instead of having them appear in multiple rows how do i return teh results in columns instead.

eg: System Name

1 Mr A

1 Mr B

2 Mr C

2 Mr D

INTO System Name1 Name2

1 Mr A Mr B

2 Mr C Mr D

SELECT CASE WHEN THEN ELSE END

Adamus

|||

SELECT CASE Name

WHEN System_ID = '1',

THEN

Name2

ELSE

Name3

END

Not sure i get you?

|||declare @.table table
(
[System] int,
[Name] varchar(5)
)

insert into @.table
select 1, 'Mr A' union all
select 1, 'Mr B' union all
select 2, 'Mr C' union all
select 2, 'Mr D'

select a.[System], [Name 1] = min(a.[Name]), [Name 2]= max(a.[Name])
from @.table a
group by a.[System]
|||

Thanks

The names Mr A, Mr B etc will be in the hundreds so don't really fancy typing them all out. There could be up to 4 or 5 different names per system.

i have tried to adapt to this but doesn;t work:-

declare @.table table

(

[System] int,

[Name] varchar(5)

)

insert into @.table

select System_ID, (firstname + ' ' + surname) as Name union all

select System_ID, (firstname + ' ' + surname) as [Name 1] union all

select System_ID, (firstname + ' ' + surname) as [Name 2]

where system = 1

From ((((dbo.System as S..........followed by my joins....

Select a.[System], [Name 1] = min(a.[Name]), [Name 2]= max(a.[Name])

from @.table a

group by a.[System]

How do i do this when i need to search for the criterea?

|||the table variable is for demonstrating the script.

use the query and change to your actual table name.

select a.[System], [Name 1] = min(a.[Name]), [Name 2]= max(a.[Name])
from @.table a
group by a.[System]|||

ok . got it working partially,

The Min and Max just returns 2 results? Some have 3 or 4 names?

|||do this in your front end application. It can be done in T-SQL but it will not be clean