Friday, February 24, 2012

How to find duplicate rows in Flat File ?

In the FLAT FILE source, I have to find the duplicate rows based on the two fields say, "bill number" & "invoice date".

The rows within flat file has like "bill number" which is duplicated on the same "invoice date".

If duplicate rows found then move the duplicate rows into another Flat File.

If not found then move the rows into Sql Server Table.

Pls provide the solution. Thank you

Since, for duplicate records, the bill numbers would be the same as would the invoice dates, how do you chose which record to keep and which to move on to another flat file? Does it matter?|||

Example

BillNo, invoicedate, billamt, shiptype,

920203348313,08/12/07,1000,A

920203348313,08/12/07,1000,A

792309510000, 08/13/07,867,C

First two rows to be moved into another FLAT FILE

Third row to be moved into SQL SERVER table.

Thanks

|||

You could use a Rank() function to identify duplicates and to select which rows are going to be discarded/kept (you could load the files to an staging table).

If you were using a relational DB as source you do it like this. Jamie has also a Rank transformation that you may want to check. You could also write your own solution in a script component.,

|||

is there any direct solution by using any component within SSIS ?

|||

Antony Kumar wrote:

is there any direct solution by using any component within SSIS ?

A script component could do this pretty easily, provided you have the data sorted by the two keys and it would also likely require a two-pass approach. The first pass to number the rows, the second to move the rows where count (rownumber) > 1

|||

Antony Kumar wrote:

Example

BillNo, invoicedate, billamt, shiptype,

920203348313,08/12/07,1000,A

920203348313,08/12/07,1000,A

792309510000, 08/13/07,867,C

First two rows to be moved into another FLAT FILE

Third row to be moved into SQL SERVER table.

Thanks

Based on this example you could use an agregation transformation to count the rows group by BillNo; that should provide an extra column with the count. Then use a conditional split to filter out rows where count>1...

|||

Rafael Salas wrote:


Based on this example you could use an agregation transformation to count the rows group by BillNo; that should provide an extra column with the count. Then use a conditional split to filter out rows where count>1...

Oh sure! Go the easy route! Not sure what I was thinking earlier.

How to find duplicate records by tree field?

I have a table named student, there are tree fields GradeID, ClassID, Seat
in it.
How can I fild the duplicate record by the tree fields?
Perhaps this will help.
SELECT GradeID, ClassID, Seat, count(*) as Rows
FROM Students
GROUP BY GradeID, ClassID, Seat
HAVING count(*) > 1
Roy Harvey
Beacon Falls, CT
On Thu, 5 Oct 2006 05:45:22 +0800, "ad" <flying@.wfes.tcc.edu.tw>
wrote:

>I have a table named student, there are tree fields GradeID, ClassID, Seat
>in it.
>How can I fild the duplicate record by the tree fields?
>
|||try this
select Count(*),GradeID, ClassID, Seat
from dbo.tablename
group by GradeID, ClassID, Seat
having count(*) > 1
the count will show you how many rows are duplicated for each instance...
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:Ox9to5$5GHA.3292@.TK2MSFTNGP02.phx.gbl...
>I have a table named student, there are tree fields GradeID, ClassID, Seat
>in it.
> How can I fild the duplicate record by the tree fields?
>
|||Thanks,
The tabe's primary is PID, how can I show the duplicate rows with PID.

> select Count(*),GradeID, ClassID, Seat
> from dbo.tablename
> group by GradeID, ClassID, Seat
> having count(*) > 1
> the count will show you how many rows are duplicated for each instance...
> --
> /*
> Warren Brunk - MCITP - SQL 2005, MCDBA
> www.techintsolutions.com
> */
>
> "ad" <flying@.wfes.tcc.edu.tw> wrote in message
> news:Ox9to5$5GHA.3292@.TK2MSFTNGP02.phx.gbl...
>

How to find duplicate records by tree field?

I have a table named student, there are tree fields GradeID, ClassID, Seat
in it.
How can I fild the duplicate record by the tree fields?Perhaps this will help.
SELECT GradeID, ClassID, Seat, count(*) as Rows
FROM Students
GROUP BY GradeID, ClassID, Seat
HAVING count(*) > 1
Roy Harvey
Beacon Falls, CT
On Thu, 5 Oct 2006 05:45:22 +0800, "ad" <flying@.wfes.tcc.edu.tw>
wrote:

>I have a table named student, there are tree fields GradeID, ClassID, Seat
>in it.
>How can I fild the duplicate record by the tree fields?
>|||try this
select Count(*),GradeID, ClassID, Seat
from dbo.tablename
group by GradeID, ClassID, Seat
having count(*) > 1
the count will show you how many rows are duplicated for each instance...
--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:Ox9to5$5GHA.3292@.TK2MSFTNGP02.phx.gbl...
>I have a table named student, there are tree fields GradeID, ClassID, Seat
>in it.
> How can I fild the duplicate record by the tree fields?
>|||Thanks,
The tabe's primary is PID, how can I show the duplicate rows with PID.

> select Count(*),GradeID, ClassID, Seat
> from dbo.tablename
> group by GradeID, ClassID, Seat
> having count(*) > 1
> the count will show you how many rows are duplicated for each instance...
> --
> /*
> Warren Brunk - MCITP - SQL 2005, MCDBA
> www.techintsolutions.com
> */
>
> "ad" <flying@.wfes.tcc.edu.tw> wrote in message
> news:Ox9to5$5GHA.3292@.TK2MSFTNGP02.phx.gbl...
>

How to find duplicate records by tree field?

I have a table named student, there are tree fields GradeID, ClassID, Seat
in it.
How can I fild the duplicate record by the tree fields?Perhaps this will help.
SELECT GradeID, ClassID, Seat, count(*) as Rows
FROM Students
GROUP BY GradeID, ClassID, Seat
HAVING count(*) > 1
Roy Harvey
Beacon Falls, CT
On Thu, 5 Oct 2006 05:45:22 +0800, "ad" <flying@.wfes.tcc.edu.tw>
wrote:
>I have a table named student, there are tree fields GradeID, ClassID, Seat
>in it.
>How can I fild the duplicate record by the tree fields?
>|||try this
select Count(*),GradeID, ClassID, Seat
from dbo.tablename
group by GradeID, ClassID, Seat
having count(*) > 1
the count will show you how many rows are duplicated for each instance...
--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"ad" <flying@.wfes.tcc.edu.tw> wrote in message
news:Ox9to5$5GHA.3292@.TK2MSFTNGP02.phx.gbl...
>I have a table named student, there are tree fields GradeID, ClassID, Seat
>in it.
> How can I fild the duplicate record by the tree fields?
>|||Thanks,
The tabe's primary is PID, how can I show the duplicate rows with PID.
> select Count(*),GradeID, ClassID, Seat
> from dbo.tablename
> group by GradeID, ClassID, Seat
> having count(*) > 1
> the count will show you how many rows are duplicated for each instance...
> --
> /*
> Warren Brunk - MCITP - SQL 2005, MCDBA
> www.techintsolutions.com
> */
>
> "ad" <flying@.wfes.tcc.edu.tw> wrote in message
> news:Ox9to5$5GHA.3292@.TK2MSFTNGP02.phx.gbl...
>>I have a table named student, there are tree fields GradeID, ClassID, Seat
>>in it.
>> How can I fild the duplicate record by the tree fields?
>

how to find duplicate data involving more than one field

How can I query a database that checks for duplicate data in a combination
of fields. For instance, LastName may have many duplicates but I want to
find duplicates of LastName combined with FirstName. Thanks.SELECT firstname, lastname
FROM YourTable
GROUP BY firstname, lastname
HAVING COUNT(*)>1
David Portas
SQL Server MVP
--|||This is great to show what is duplicated and by adding changing Select to co
unt(*) I was able to see how many times it was duplicated. Are you able to t
ake this 1 step further and actually return all duplicated and complete reco
rds? EG. John,Smith is duplicated 3 times but the City is different in each
case. Can you return the 3 first,last,city records?
Robert Lassiter
quote:
Originally posted by David Portas
SELECT firstname, lastname
FROM YourTable
GROUP BY firstname, lastname
HAVING COUNT(*)>1
David Portas
SQL Server MVP
--

|||On Fri, 16 Dec 2005 12:16:57 -0600, rlassiter wrote:

>This is great to show what is duplicated and by adding changing Select
>to count(*) I was able to see how many times it was duplicated. Are you
>able to take this 1 step further and actually return all duplicated and
>complete records? EG. John,Smith is duplicated 3 times but the City is
>different in each case. Can you return the 3 first,last,city records?
>Robert Lassiter
Hi Robert,
Here's one method:
SELECT a.firstname, a.lastname, a.city
FROM YourTable AS a
WHERE (SELECT COUNT(*)
FROM YourTable AS b
WHERE b.firstname = a.firstname
AND b.lastname = a.lastname) > 1
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

How to find determine estimated time for restoring a terabyte database

Hi,

Is there any way i can determine the total time a database of size 1 tera byte will take while restoring it?

Or if anyone has hands on restoring a terabyte database and can share the time taken it would be of great help.

Thanks,

This depends on your disk subsystem.

What is the maximum throughput per second of your disk subsystem?

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||SEe my http://sqlserver-qa.net/blogs/perftune/archive/2007/06/12/get-backup-and-restore-performance-stats-with-a-dmv.aspx fyi.

How to find Dependent/Referenced Objects of a Stored Procedure?

Hi Frens,

Could anybody tell me how can I find all the database objects that are used in /referenced by/called by/dependent on a given stored procedure? In other words, I am looking for something like a stored procedure or a function that takes as input the name of a stored procedure and outputs all the names of the tables, functions, procedures, cursors and etc. database objects that are used in that procedure. Could you please give me suggestions or possible answers for this?

Thanks a lot for your time.
Regards,
-Ram.Sure, take this query here:

Select OBJECT_NAME(id),OBJECT_NAME(depid) from sysdepends

WHERE id = OBJECT_ID('YourPrcoedurename')

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||Thanks Jens.

How to find dependent objects?

Hi,
Is there any way to find out all the dependent objects in sql server?
Sp_depends doesnt do it sysdepends table corruption.
Any thoughts?
Thanks
> Is there any way to find out all the dependent objects in sql server?
> Sp_depends doesnt do it sysdepends table corruption.
You might want to check a 3rd party tol, for example
http://www.red-gate.com/sql/more/sysdepends.htm.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

How to find dependent objects?

Hi,
Is there any way to find out all the dependent objects in sql server?
Sp_depends doesnt do it sysdepends table corruption.
Any thoughts?
Thanks> Is there any way to find out all the dependent objects in sql server?
> Sp_depends doesnt do it sysdepends table corruption.
You might want to check a 3rd party tol, for example
http://www.red-gate.com/sql/more/sysdepends.htm.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

How to find dependent objects?

Hi,
Is there any way to find out all the dependent objects in sql server?
Sp_depends doesnt do it sysdepends table corruption.
Any thoughts?
Thanks> Is there any way to find out all the dependent objects in sql server?
> Sp_depends doesnt do it sysdepends table corruption.
You might want to check a 3rd party tol, for example
http://www.red-gate.com/sql/more/sysdepends.htm.
--
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

How to find Dependencies ?

I am looking for code or a solution to find all
dependencies in a .db fast and simple (or code). Any
suggestions would be great!
Example:
Here is the dependencies among these 4 tables:
1) Publishers (base table): does not depend on other
tables.
2) Authors (base table): does not depend on other tables.
3) Titles: has foreign key which depend on publishers
table.
4) Titleauthor: has 2 foreign keys which depend on
authors and publishers titleswhy?
is it because you want to make sure your new code doesn't
break any existing code?
check out DB Ghost @. www.dbghost.com - it can guarentee
your code doesn't break anything and make deploying your
changes a breeze.
>--Original Message--
>I am looking for code or a solution to find all
>dependencies in a .db fast and simple (or code). Any
>suggestions would be great!
>Example:
>Here is the dependencies among these 4 tables:
>1) Publishers (base table): does not depend on other
>tables.
>2) Authors (base table): does not depend on other tables.
>3) Titles: has foreign key which depend on publishers
>table.
>4) Titleauthor: has 2 foreign keys which depend on
>authors and publishers titles
>.
>|||Have you looked into the stored procedure sp_depends?
-- Keith, SQL Server MVP
"Mike A" <mike@.countrymedic.com> wrote in message =news:000301c34a11$6be5af20$a101280a@.phx.gbl...
> I am looking for code or a solution to find all > dependencies in a .db fast and simple (or code). Any > suggestions would be great!
> > Example:
> Here is the dependencies among these 4 tables:
> 1) Publishers (base table): does not depend on other > tables.
> 2) Authors (base table): does not depend on other tables.
> 3) Titles: has foreign key which depend on publishers > table.
> 4) Titleauthor: has 2 foreign keys which depend on > authors and publishers titles
>|||Yes, sp_depends does not solve the issue. It shows
dependencies on sp.
>--Original Message--
>Have you looked into the stored procedure sp_depends?
>--
>Keith, SQL Server MVP
>"Mike A" <mike@.countrymedic.com> wrote in message
news:000301c34a11$6be5af20$a101280a@.phx.gbl...
>> I am looking for code or a solution to find all
>> dependencies in a .db fast and simple (or code). Any
>> suggestions would be great!
>> Example:
>> Here is the dependencies among these 4 tables:
>> 1) Publishers (base table): does not depend on other
>> tables.
>> 2) Authors (base table): does not depend on other
tables.
>> 3) Titles: has foreign key which depend on publishers
>> table.
>> 4) Titleauthor: has 2 foreign keys which depend on
>> authors and publishers titles
>.
>|||No trying to determine population order of the .db built
in another state.
>--Original Message--
>why?
>is it because you want to make sure your new code
doesn't
>break any existing code?
>check out DB Ghost @. www.dbghost.com - it can guarentee
>your code doesn't break anything and make deploying your
>changes a breeze.
>>--Original Message--
>>I am looking for code or a solution to find all
>>dependencies in a .db fast and simple (or code). Any
>>suggestions would be great!
>>Example:
>>Here is the dependencies among these 4 tables:
>>1) Publishers (base table): does not depend on other
>>tables.
>>2) Authors (base table): does not depend on other
tables.
>>3) Titles: has foreign key which depend on publishers
>>table.
>>4) Titleauthor: has 2 foreign keys which depend on
>>authors and publishers titles
>>.
>.
>|||hi Mike,
"Mike A" <mike@.countrymedic.com> ha scritto nel messaggio
news:000301c34a11$6be5af20$a101280a@.phx.gbl...
> I am looking for code or a solution to find all
> dependencies in a .db fast and simple (or code). Any
> suggestions would be great!
> Example:
> Here is the dependencies among these 4 tables:
> 1) Publishers (base table): does not depend on other
> tables.
> 2) Authors (base table): does not depend on other tables.
> 3) Titles: has foreign key which depend on publishers
> table.
> 4) Titleauthor: has 2 foreign keys which depend on
> authors and publishers titles
You can have a look at the UNDOCUMENTED (unsupported) stored procedure
sp_MSforeachtable..
sp_MSforeachtable can execute the command you pass as a parameter for each
table present in your database and you can try using sp_depends, that
returns all dependencies for the specified ('?') table object
EXEC sp_MSforeachtable 'SELECT ''?'' AS ObjName EXEC sp_depends ''?'''
you'll get an output similar to
ObjName
--
dbo.tableXXXXX
no object refers to this object....
or
ObjName
--
dbo.tableXXXXX
In the current database, the specified object is referenced by the
following:
name type
xxxxx xxxxx
to list FK constraint you can use a select which actually includes some
joins....
mixing the 2 command you can give this a try...
----
EXEC sp_MSforeachtable 'SELECT ''?'' AS ObjName EXEC sp_depends ''?'''
DECLARE @.MasterCMD VARCHAR (1000)
SET @.MasterCMD ='SELECT ''?'' AS ObjName
PRINT ''sp_depends''
PRINT ''--''
PRINT ''fk_scan''
PRINT ''--''
SELECT SO3.NAME FK_NAME, ''['' + SU.NAME + ''].['' + SO.NAME + '']''
FROM SYSFOREIGNKEYS SYSFK
--Foreign Key Constraint - Table info
INNER JOIN (SELECT UID, ID, NAME FROM SYSOBJECTS WHERE XTYPE = ''U'') SO
ON SYSFK.FKEYID = SO.ID
INNER JOIN (SELECT UID, ID, NAME FROM SYSOBJECTS WHERE XTYPE = ''U'') SO2
ON SYSFK.RKEYID = SO2.ID
--Name and ID of the FOREIGN KEY constraint
INNER JOIN (SELECT ID, NAME FROM SYSOBJECTS) SO3 ON SYSFK.CONSTID = SO3.ID
--Foreign Key Constraint - Owner info
INNER JOIN SYSUSERS SU ON SO.UID = SU.UID
--Referenced in the FOREIGN KEY constraint - Owner info
INNER JOIN SYSUSERS SU2 ON SO2.UID = SU2.UID
WHERE SU.NAME + ''.'' + SO.NAME = ''?'''
EXEC sp_MSforeachtable @.MasterCMD
----
you must be warned that Microsot does not recommend the use of UNDOCUMENTED
stored procedures that are unsupported and system objects direct
manipulation
hth
Andrea Montanari
montanari_andrea@.virgilio.it
http://www.asql.biz/DbaMgr.shtm
DbaMgr2k ver 0.4.0 - DbaMgr ver 0.50.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply|||It also shows dependencies on a table...
USE pubs
GO
exec sp_depends 'authors'
-- Keith, SQL Server MVP
"Mike A" <mike@.countrymedic.com> wrote in message =news:0a3001c34a22$5c817f80$a501280a@.phx.gbl...
> Yes, sp_depends does not solve the issue. It shows > dependencies on sp.
> > > >--Original Message--
> >Have you looked into the stored procedure sp_depends?
> >
> >-- > >Keith, SQL Server MVP
> > > >"Mike A" <mike@.countrymedic.com> wrote in message > news:000301c34a11$6be5af20$a101280a@.phx.gbl...
> >> I am looking for code or a solution to find all > >> dependencies in a .db fast and simple (or code). Any > >> suggestions would be great!
> >> > >> Example:
> >> Here is the dependencies among these 4 tables:
> >> 1) Publishers (base table): does not depend on other > >> tables.
> >> 2) Authors (base table): does not depend on other > tables.
> >> 3) Titles: has foreign key which depend on publishers > >> table.
> >> 4) Titleauthor: has 2 foreign keys which depend on > >> authors and publishers titles
> >> > >.
> >

How to find day from date

Can anybody please tell me how to extact the day from a date

Quote:

Originally Posted by MyQuery2007

Can anybody please tell me how to extact the day from a date


select datepart(day, getdate())

How to find date of Month

Hi

Problem:

one table "tbl_SalesReporting" in this table salesEr every day submit his information.

i need which day salesEr not submit his information. this is check up to current date.

E.G:

salesEr submit information start this date "1/04/2006" to "17/04/2006" and

currentdate: 20/04/2006

i need 18/04/2006,19/04/2006 this date Using SQL queries......

Please help me......

In SQL Server 2005, I use a CTE to hold all dates up to today. Then find out which date is not in your list.

Here is the code:

With reportMonthdatesCTE(mydates)
AS
(select dateadd(ms,+3,DATEADD(mm, DATEDIFF(mm,0,getdate() ), 0))

union all
select dateadd(d, 1, mydates) from reportMonthdatesCTE WHERE Month(mydates)=Month(getdate()) and mydates<=getdate()


)
SELECT convert(nchar(8),mydates, 112) as salesEr FROM reportMonthdatesCTE WHERE convert(nchar(8),mydates, 112) not in
(SELECT convert(nchar(8),salesEr, 112)
FROM tbl_SalesReporting
WHERE Month(salesEr)=Month(getdate()) and salesEr<=getdate())

|||

Hi dear......

i m use SQL server 2000 so please help me......

|||Jayu, my suggestion is to create a "Calendar" table which holds all of the dates for the year. Then you can run a query from to see which dates in your tbl_SalesReporting table are missing. Assuming the data types of your columns are DateTime, the query would look something like this:
  
SELECT *FROM tbl_SalesReportingWHERE salesERDateBETWEEN @.monthStartDateand @.CurrentDateANDCONVERT(char(8),salesErDate,112)NOT IN (SELECT calendardateFROM CalendarWHERE calendarDateBETWEEN @.monthStartDateAND @.CurrentDate)
|||

Jayu:

You can build a calendar table in your database or create a UDF in SQL server 2000. I did this for you. Please check it to see whether there is any problem.

Here is your solution:

Part 1: Create a function to hold the partial calendar:

set

ANSI_NULLSON

set

QUOTED_IDENTIFIERON

go

CREATE

function [dbo].[monthCalendar](@.Checkdatedatetime)

returns

@.monthCalendartable( DatesInMonthdatetime

)

as

BEGIN

declare

@.dint

declare

@.maxdayint

set

@.d=0

set

@.maxday=Day(@.Checkdate)

while

@.d< @.maxday

BEGIN

insert

@.monthCalendar(DatesInMonth)

select

dateadd(ms,+3,DATEADD(mm,DATEDIFF(mm,0,@.Checkdate), @.d))

set

@.d=@.d+1

END

--end of the loop for construction the calendar table

RETURN

END

Part 2: query part:

SELECT

convert(nchar(8),DatesInMonth, 112)as salesErFROM [dbo].[monthCalendar](getdate())WHEREconvert(nchar(8),DatesInMonth, 112)notin

(

SELECTconvert(nchar(8),salesEr, 112)

FROM

tbl_SalesReporting

WHERE

Month(salesEr)=Month(getdate())and salesEr<=getdate())

I like 2005 version's solution. Enjoy.

|||

Hi

thanks for reply

i have create UDF function and run this query

SELECT convert(nchar(8),DatesInMonth, 112) as SalesEr
FROM [dbo].[monthCalendar] (getdate())
WHERE convert(nchar(8),DatesInMonth, 112)
not in
(SELECT convert(nchar(8),SalesEr, 112)
FROMtbl_SalesReporting
WHERE Month(SalesEr)=Month(getdate()) and SalesEr<=getdate())

but i m fashing error.......

Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '('.

Please help me.........

|||

Hilimno

many many Thanks

solve my problems..........

again thanks.......

|||

Hi Limno

I can build a calendar table in your database or create a UDF in SQL server 2000. this is execute successfully

but i require this type

i pass date into the query and i require date (which is not enter in database) between this date and current date.

e.g:

Startdate:20/4/2006

Enddate: currentDate suppose 03/05/2006

database table name "tbl_Sales" and datefield Name "entryDate"

entryDate: 20/4/2006 ,21/4/2006,22/4/2006,23/4/2006,24/4/2006,26/4/2006,27/4/2006,28/4/2006,29/4/2006

30/4/2006,01/5/2006

i require this date

25/4/2006, 02/5/2006, 03/5/2006

Please help me.........

|||

You need a customized calendar for all dates in a year.

Here is the modified solution for your case now:

SELECT

convert(nchar(8),Dates, 112)as salesErFROM [dbo].[yearCalendar]WHERE

(

CONVERT(nchar(8), Dates, 112)>='20060420'and Dates<=getdate())AND

convert

(nchar(8),Dates, 112)notin

(

SELECT

convert(nchar(8),salesEr, 112)

FROM

tbl_SalesReporting

WHERE

CONVERT(nchar(8), salesEr, 112)>='20060420'and salesEr<=getdate())

If you need to use this query often, you should convert it into a Stored Procedure with a datetime parameter.

Notice the date convert function here. You can check Book Online to choose the format you like most. What I am using here is ISO standard yyyymmdd.

Here is the code for the calendar table:

USE

mytest--your table

GO

CREATE

table yearCalendar(Datesdatetime)

GO

declare

@.nint

declare

@.maxnint

declare

@.begindatedatetime

set

@.n=1

set

@.maxn=365-- Number of days added to the calendar

set

@.begindate=convert(datetime,'01/01/2006')-- Initial date for the first run is todays date

set

@.begindate=@.begindate-1

while

@.n<= @.maxn

begin

insert

into yearCalendar(Dates)select @.begindate+@.n

set

@.n=@.n+1

end

GO

--Source:http://www.databasejournal.com/features/mssql/article.php/3502256

|||

Hi Dear.......

it's working ......

Thanks a lot dear........

How to find database table and their field name run time.

I am using sql server as back end. Through connection stringI am getting database name. But in A dropdown I want to show list of table inthat database. And in another B drop down I want to show fields of tableselected in A dropdown. can any one help in getting the field .

The sp_Tables query will return the tables in a database andsp_Columns returns the column names

http://www.vb-tips.com/dbpages.aspx?ID=9e2d9af4-3909-421d-b422-87c1d376674d

|||

And if you want to dig deeper into the structure of the database or server, you can use SQL-DMO in SQL Server 2000 or SMO (SQL Management Objects) in SQL Server 2005.

Don

How to find database in VC#?

Hi There!

I am very new to VC# and SQL Express. I made a databse and a table in SQL Express, but I can not find it when I open up VC# Express and search through the Database Explorer. Can anyone provide me with information on how to get them working together? I have searched online for a while, but so far no good answers. Thank you!

How did you make the database? How you create a database in C# will dictate where it was created and how you access it.

Mike

How to find data/text within SQL DB

Hi there, posted the same question in FULLTEXT group, but I think this group
could also help me, cos it is not just FULLTEXT related
I have a problem and don't know how to resolve it. I had sharepoint portal
server 2003, then it was upgraded to 2007, but after that two meeting
workspace been lost. Lost from sharepoint site, but not from the DB. Wrote
to sharepoint group and one guy just started with step buy step guide about
how could I find it within SQL DB
http://www.developerfood.com/lost-meeting-workspace-after-2003to2007-inplace-upgrade/microsoft-public-sharepoint-portalserver/44bdf402-c511-45a8-8452-bb1d95cb2908/article.aspx
but he never replied me
Please could some one help me with that?
Thank you in advance
Hi
"Guzun, Alex" wrote:

> Hi there, posted the same question in FULLTEXT group, but I think this group
> could also help me, cos it is not just FULLTEXT related
> I have a problem and don't know how to resolve it. I had sharepoint portal
> server 2003, then it was upgraded to 2007, but after that two meeting
> workspace been lost. Lost from sharepoint site, but not from the DB. Wrote
> to sharepoint group and one guy just started with step buy step guide about
> how could I find it within SQL DB
> http://www.developerfood.com/lost-meeting-workspace-after-2003to2007-inplace-upgrade/microsoft-public-sharepoint-portalserver/44bdf402-c511-45a8-8452-bb1d95cb2908/article.aspx
> but he never replied me
> Please could some one help me with that?
> Thank you in advance
>
All the posts don't seem to be available! http://tinyurl.com/yr38vs shows
more replies. I don't know sharepoint so I am not sure what should be in the
sites table, but if you could restore a copy of the database to a different
server (or under a different database name on the same server) you will be
able to compare the contents and see if they are different.
John

How to find data/text within SQL DB

Hi there, posted the same question in FULLTEXT group, but I think this group
could also help me, cos it is not just FULLTEXT related :)
I have a problem and don't know how to resolve it. I had sharepoint portal
server 2003, then it was upgraded to 2007, but after that two meeting
workspace been lost. Lost from sharepoint site, but not from the DB. Wrote
to sharepoint group and one guy just started with step buy step guide about
how could I find it within SQL DB
http://www.developerfood.com/lost-meeting-workspace-after-2003to2007-inplace-upgrade/microsoft-public-sharepoint-portalserver/44bdf402-c511-45a8-8452-bb1d95cb2908/article.aspx
but he never replied me
Please could some one help me with that?
Thank you in advanceHi
"Guzun, Alex" wrote:
> Hi there, posted the same question in FULLTEXT group, but I think this group
> could also help me, cos it is not just FULLTEXT related :)
> I have a problem and don't know how to resolve it. I had sharepoint portal
> server 2003, then it was upgraded to 2007, but after that two meeting
> workspace been lost. Lost from sharepoint site, but not from the DB. Wrote
> to sharepoint group and one guy just started with step buy step guide about
> how could I find it within SQL DB
> http://www.developerfood.com/lost-meeting-workspace-after-2003to2007-inplace-upgrade/microsoft-public-sharepoint-portalserver/44bdf402-c511-45a8-8452-bb1d95cb2908/article.aspx
> but he never replied me
> Please could some one help me with that?
> Thank you in advance
>
All the posts don't seem to be available! http://tinyurl.com/yr38vs shows
more replies. I don't know sharepoint so I am not sure what should be in the
sites table, but if you could restore a copy of the database to a different
server (or under a different database name on the same server) you will be
able to compare the contents and see if they are different.
John

How to find data/text within SQL DB

Hi there, posted the same question in FULLTEXT group, but I think this group
could also help me, cos it is not just FULLTEXT related
I have a problem and don't know how to resolve it. I had sharepoint portal
server 2003, then it was upgraded to 2007, but after that two meeting
workspace been lost. Lost from sharepoint site, but not from the DB. Wrote
to sharepoint group and one guy just started with step buy step guide about
how could I find it within SQL DB
http://www.developerfood.com/lost-m.../>
rticle.aspx
but he never replied me
Please could some one help me with that?
Thank you in advanceHi
"Guzun, Alex" wrote:

> Hi there, posted the same question in FULLTEXT group, but I think this gro
up
> could also help me, cos it is not just FULLTEXT related
> I have a problem and don't know how to resolve it. I had sharepoint portal
> server 2003, then it was upgraded to 2007, but after that two meeting
> workspace been lost. Lost from sharepoint site, but not from the DB. Wrote
> to sharepoint group and one guy just started with step buy step guide abou
t
> how could I find it within SQL DB
> http://www.developerfood.com/lost-m...
/article.aspx
> but he never replied me
> Please could some one help me with that?
> Thank you in advance
>
All the posts don't seem to be available! http://tinyurl.com/yr38vs shows
more replies. I don't know sharepoint so I am not sure what should be in the
sites table, but if you could restore a copy of the database to a different
server (or under a different database name on the same server) you will be
able to compare the contents and see if they are different.
John

how to find Data Type of a Declared Variable

how to find Data Type of a Declared Variable in sql server?
i googled a lot but could not find ans.
suppose
Declare @.Var1 int
now i want to find datatype of @.var1.
plz help.Hi Amit
Can you explain why you need to do this?
Variables are extremely local in SQL Server; they have no existence outside
the batch where they are declared. So you can never see or use, much less
find out the datatype, from any variable in any other batch. For variables
in the current batch, whoever wrote the batch has to define them so why
wouldn't that information be available?
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://sqlblog.com
"amit sharma" <amit sharma@.discussions.microsoft.com> wrote in message
news:A07C1CC0-B0C2-4D98-80C7-DEDB221FC783@.microsoft.com...
> how to find Data Type of a Declared Variable in sql server?
> i googled a lot but could not find ans.
> suppose
> Declare @.Var1 int
> now i want to find datatype of @.var1.
> plz help.
>|||Typing and variables are relatively insignificant in sql. They are so
alien that MS has tried to create a bypass for programmers who think
in such terms. I suggest you look at LINQ to Sql for a way to make
sql understandable and workable in a natural programming enivornment.
www.beyondsql.blogspot.com

how to find Data Type of a Declared Variable

how to find Data Type of a Declared Variable in sql server?
i googled a lot but could not find ans.
suppose
Declare @.Var1 int
now i want to find datatype of @.var1.
plz help.
Hi Amit
Can you explain why you need to do this?
Variables are extremely local in SQL Server; they have no existence outside
the batch where they are declared. So you can never see or use, much less
find out the datatype, from any variable in any other batch. For variables
in the current batch, whoever wrote the batch has to define them so why
wouldn't that information be available?
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://sqlblog.com
"amit sharma" <amit sharma@.discussions.microsoft.com> wrote in message
news:A07C1CC0-B0C2-4D98-80C7-DEDB221FC783@.microsoft.com...
> how to find Data Type of a Declared Variable in sql server?
> i googled a lot but could not find ans.
> suppose
> Declare @.Var1 int
> now i want to find datatype of @.var1.
> plz help.
>
|||Typing and variables are relatively insignificant in sql. They are so
alien that MS has tried to create a bypass for programmers who think
in such terms. I suggest you look at LINQ to Sql for a way to make
sql understandable and workable in a natural programming enivornment.
www.beyondsql.blogspot.com

how to find Data Type of a Declared Variable

how to find Data Type of a Declared Variable in sql server?
i googled a lot but could not find ans.
suppose
Declare @.Var1 int
now i want to find datatype of @.var1.
plz help.Hi Amit
Can you explain why you need to do this?
Variables are extremely local in SQL Server; they have no existence outside
the batch where they are declared. So you can never see or use, much less
find out the datatype, from any variable in any other batch. For variables
in the current batch, whoever wrote the batch has to define them so why
wouldn't that information be available?
--
HTH
Kalen Delaney, SQL Server MVP
www.InsideSQLServer.com
http://sqlblog.com
"amit sharma" <amit sharma@.discussions.microsoft.com> wrote in message
news:A07C1CC0-B0C2-4D98-80C7-DEDB221FC783@.microsoft.com...
> how to find Data Type of a Declared Variable in sql server?
> i googled a lot but could not find ans.
> suppose
> Declare @.Var1 int
> now i want to find datatype of @.var1.
> plz help.
>|||Typing and variables are relatively insignificant in sql. They are so
alien that MS has tried to create a bypass for programmers who think
in such terms. I suggest you look at LINQ to Sql for a way to make
sql understandable and workable in a natural programming enivornment.
www.beyondsql.blogspot.com

How to find Data Space Used?

This feels like a stupid question as it seems very basic, but I have
been unable to find an answer to it!
Basically all I want is a SQL command to return the % data space used
in a particular database. I can find it for the log space with the
following command,
DBCC perflog
but not one that returns the % of the data space used. Does one
exist? I am using SQL 2000 BTW, but would be interested in all
versions of SQL...
Many thanks!sp_spaceused '
<nielsonj1976@.yahoo.co.uk> wrote in message
news:1188894429.748919.35510@.d55g2000hsg.googlegroups.com...
> This feels like a stupid question as it seems very basic, but I have
> been unable to find an answer to it!
> Basically all I want is a SQL command to return the % data space used
> in a particular database. I can find it for the log space with the
> following command,
> DBCC perflog
> but not one that returns the % of the data space used. Does one
> exist? I am using SQL 2000 BTW, but would be interested in all
> versions of SQL...
> Many thanks!
>|||sp_spaceused is unreliable in 2000 and doesn't account for all pages in
2005.
This code is a little sloppy, but it works. Just note, it is counting the
64KB extents allocated/used.
Oh, and though I wrote it, this is really as much Tibor's code as it is mine
:)
DECLARE @.DB sysname
DECLARE @.SQL nvarchar(255)
if exists ( select * from tempdb..sysobjects where name LIKE
'#FileStats__%' ) drop table
#FileStats
CREATE TABLE #FileStats(
[FileId] INT,
[FileGroup] INT,
[TotalExtents] INT,
[UsedExtents] INT,
[Name] sysname,
[Filename] varchar(255)
)
DECLARE @.FileStats TABLE (
[FileId] INT,
[FileGroup] INT,
[TotalExtents] INT,
[UsedExtents] INT,
[Name] sysname,
[Filename] varchar(255)
)
DECLARE cDatabases CURSOR FOR
SELECT sdb.name
FROM master.dbo.sysdatabases sdb
WHERE status & 32 != 32
AND status & 64 != 64
AND status & 128 != 128
AND status & 256 != 256
AND status & 512 != 512
AND status & 1024 != 1024
AND status & 4096 != 4096
AND status & 32768 !=32768
OPEN cDatabases
FETCH FROM cDatabases INTO @.DB
WHILE (@.@.FETCH_STATUS = 0)
BEGIN
DELETE FROM #FileStats
SET @.SQL = 'USE ' + @.DB + '; INSERT INTO #FileStats EXEC (''DBCC
SHOWFILESTATS'')'
EXEC (@.SQL)
UPDATE #FileStats SET name = @.DB
INSERT INTO @.FileStats SELECT * FROM #FileStats
FETCH FROM cDatabases INTO @.DB
END
CLOSE cDatabases
DEALLOCATE cDatabases
SELECT
[Name]
,[TotalExtents]*64/1024. AS TotalExtInMB
,[UsedExtents]*64/1024. AS UsedExtInMB
,([TotalExtents] - [UsedExtents]) / 16. AS UnAllocExtInMB --* 64 / 1024. AS
UnAllocExtInMB
FROM @.FileStats
--exec sp_spaceused
DBCC sqlperf(logspace)
<nielsonj1976@.yahoo.co.uk> wrote in message
news:1188894429.748919.35510@.d55g2000hsg.googlegroups.com...
> This feels like a stupid question as it seems very basic, but I have
> been unable to find an answer to it!
> Basically all I want is a SQL command to return the % data space used
> in a particular database. I can find it for the log space with the
> following command,
> DBCC perflog
> but not one that returns the % of the data space used. Does one
> exist? I am using SQL 2000 BTW, but would be interested in all
> versions of SQL...
> Many thanks!
>|||I like the output, Jay.
Anything you like to share with the public? If you have a blog or a page somewhere, I can link to it
from my blog...
(
How about adding something like below to the first SELECT column list?
...
,CASE WHEN CAST([UsedExtents] AS decimal(12,2))/TotalExtents > 0.7 THEN 1 ELSE 0 END AS "Almost
Full"
FROM @.FileStats
)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <spam@.nospam.org> wrote in message news:OMN8UQ77HHA.5796@.TK2MSFTNGP05.phx.gbl...
> sp_spaceused is unreliable in 2000 and doesn't account for all pages in 2005.
> This code is a little sloppy, but it works. Just note, it is counting the 64KB extents
> allocated/used.
> Oh, and though I wrote it, this is really as much Tibor's code as it is mine :)
> DECLARE @.DB sysname
> DECLARE @.SQL nvarchar(255)
> if exists ( select * from tempdb..sysobjects where name LIKE '#FileStats__%' ) drop table
> #FileStats
> CREATE TABLE #FileStats(
> [FileId] INT,
> [FileGroup] INT,
> [TotalExtents] INT,
> [UsedExtents] INT,
> [Name] sysname,
> [Filename] varchar(255)
> )
> DECLARE @.FileStats TABLE (
> [FileId] INT,
> [FileGroup] INT,
> [TotalExtents] INT,
> [UsedExtents] INT,
> [Name] sysname,
> [Filename] varchar(255)
> )
> DECLARE cDatabases CURSOR FOR
> SELECT sdb.name
> FROM master.dbo.sysdatabases sdb
> WHERE status & 32 != 32
> AND status & 64 != 64
> AND status & 128 != 128
> AND status & 256 != 256
> AND status & 512 != 512
> AND status & 1024 != 1024
> AND status & 4096 != 4096
> AND status & 32768 !=32768
> OPEN cDatabases
> FETCH FROM cDatabases INTO @.DB
> WHILE (@.@.FETCH_STATUS = 0)
> BEGIN
> DELETE FROM #FileStats
> SET @.SQL = 'USE ' + @.DB + '; INSERT INTO #FileStats EXEC (''DBCC SHOWFILESTATS'')'
> EXEC (@.SQL)
> UPDATE #FileStats SET name = @.DB
> INSERT INTO @.FileStats SELECT * FROM #FileStats
> FETCH FROM cDatabases INTO @.DB
> END
> CLOSE cDatabases
> DEALLOCATE cDatabases
> SELECT
> [Name]
> ,[TotalExtents]*64/1024. AS TotalExtInMB
> ,[UsedExtents]*64/1024. AS UsedExtInMB
> ,([TotalExtents] - [UsedExtents]) / 16. AS UnAllocExtInMB --* 64 / 1024. AS UnAllocExtInMB
> FROM @.FileStats
> --exec sp_spaceused
> DBCC sqlperf(logspace)
> <nielsonj1976@.yahoo.co.uk> wrote in message
> news:1188894429.748919.35510@.d55g2000hsg.googlegroups.com...
>> This feels like a stupid question as it seems very basic, but I have
>> been unable to find an answer to it!
>> Basically all I want is a SQL command to return the % data space used
>> in a particular database. I can find it for the log space with the
>> following command,
>> DBCC perflog
>> but not one that returns the % of the data space used. Does one
>> exist? I am using SQL 2000 BTW, but would be interested in all
>> versions of SQL...
>> Many thanks!
>|||I don't have a blog, but I've been toying with creating one of those fee web
pages, like geocities, or something as I have a few scripts I would like to
share.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:O1vWA%2377HHA.1188@.TK2MSFTNGP04.phx.gbl...
>I like the output, Jay.
> Anything you like to share with the public? If you have a blog or a page
> somewhere, I can link to it from my blog...
> (
> How about adding something like below to the first SELECT column list?
> ...
> ,CASE WHEN CAST([UsedExtents] AS decimal(12,2))/TotalExtents > 0.7 THEN 1
> ELSE 0 END AS "Almost Full"
> FROM @.FileStats
> )
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <spam@.nospam.org> wrote in message
> news:OMN8UQ77HHA.5796@.TK2MSFTNGP05.phx.gbl...
>> sp_spaceused is unreliable in 2000 and doesn't account for all pages in
>> 2005.
>> This code is a little sloppy, but it works. Just note, it is counting the
>> 64KB extents allocated/used.
>> Oh, and though I wrote it, this is really as much Tibor's code as it is
>> mine :)
>> DECLARE @.DB sysname
>> DECLARE @.SQL nvarchar(255)
>> if exists ( select * from tempdb..sysobjects where name LIKE
>> '#FileStats__%' ) drop table
>> #FileStats
>> CREATE TABLE #FileStats(
>> [FileId] INT,
>> [FileGroup] INT,
>> [TotalExtents] INT,
>> [UsedExtents] INT,
>> [Name] sysname,
>> [Filename] varchar(255)
>> )
>> DECLARE @.FileStats TABLE (
>> [FileId] INT,
>> [FileGroup] INT,
>> [TotalExtents] INT,
>> [UsedExtents] INT,
>> [Name] sysname,
>> [Filename] varchar(255)
>> )
>> DECLARE cDatabases CURSOR FOR
>> SELECT sdb.name
>> FROM master.dbo.sysdatabases sdb
>> WHERE status & 32 != 32
>> AND status & 64 != 64
>> AND status & 128 != 128
>> AND status & 256 != 256
>> AND status & 512 != 512
>> AND status & 1024 != 1024
>> AND status & 4096 != 4096
>> AND status & 32768 !=32768
>> OPEN cDatabases
>> FETCH FROM cDatabases INTO @.DB
>> WHILE (@.@.FETCH_STATUS = 0)
>> BEGIN
>> DELETE FROM #FileStats
>> SET @.SQL = 'USE ' + @.DB + '; INSERT INTO #FileStats EXEC (''DBCC
>> SHOWFILESTATS'')'
>> EXEC (@.SQL)
>> UPDATE #FileStats SET name = @.DB
>> INSERT INTO @.FileStats SELECT * FROM #FileStats
>> FETCH FROM cDatabases INTO @.DB
>> END
>> CLOSE cDatabases
>> DEALLOCATE cDatabases
>> SELECT
>> [Name]
>> ,[TotalExtents]*64/1024. AS TotalExtInMB
>> ,[UsedExtents]*64/1024. AS UsedExtInMB
>> ,([TotalExtents] - [UsedExtents]) / 16. AS UnAllocExtInMB --* 64 / 1024.
>> AS UnAllocExtInMB
>> FROM @.FileStats
>> --exec sp_spaceused
>> DBCC sqlperf(logspace)
>> <nielsonj1976@.yahoo.co.uk> wrote in message
>> news:1188894429.748919.35510@.d55g2000hsg.googlegroups.com...
>> This feels like a stupid question as it seems very basic, but I have
>> been unable to find an answer to it!
>> Basically all I want is a SQL command to return the % data space used
>> in a particular database. I can find it for the log space with the
>> following command,
>> DBCC perflog
>> but not one that returns the % of the data space used. Does one
>> exist? I am using SQL 2000 BTW, but would be interested in all
>> versions of SQL...
>> Many thanks!
>>
>

how to find data mining 's example

how to find data mining 's example from sql2005

how to apply data mining in project

This might be a good starting point...

http://msdn2.microsoft.com/en-us/library/ms175595(SQL.90).aspx

|||

There is a Data Mining forum and I am sure you will find relevant information there.

http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=81&SiteID=1

How to find currpted backup file

1.How can i find out whether the backup file is currpted or good enough to
restore.
2.Is there any other ways to restore db without loosing any data when my
database files (mdf & Ldf) and my backup file is currupt
ThanksHello,
1.How can i find out whether the backup file is currpted or good enough to
restore.
RESTORE VERIFY ONLY
2. Is there any other ways to restore db without loosing any data when my
database files (mdf & Ldf) and my backup file is currupt
If both MDF and LDF is corrupted. You cant do much. Only way is to
restore from good backup. Incase if ur LDF is giving issues or if u have 803
error you can
1. Create a database with same
2. Stop SQL Server and copy the corrupted MDF above the new MDF file
3. Start SQL Server
4. Datbaase will be marked suspect. Change the mode to EMergency
5, Using DTS or Scripts to copy the data
Steps will varry based on the situation.
Thanks
Hari
"Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in
message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
> 1.How can i find out whether the backup file is currpted or good enough to
> restore.
> 2.Is there any other ways to restore db without loosing any data when my
> database files (mdf & Ldf) and my backup file is currupt
> Thanks|||Thanks Hari
"Hari Prasad" wrote:

> Hello,
> 1.How can i find out whether the backup file is currpted or good enough to
> restore.
> RESTORE VERIFY ONLY
> 2. Is there any other ways to restore db without loosing any data when my
> database files (mdf & Ldf) and my backup file is currupt
> If both MDF and LDF is corrupted. You cant do much. Only way is to
> restore from good backup. Incase if ur LDF is giving issues or if u have 8
03
> error you can
> 1. Create a database with same
> 2. Stop SQL Server and copy the corrupted MDF above the new MDF file
> 3. Start SQL Server
> 4. Datbaase will be marked suspect. Change the mode to EMergency
> 5, Using DTS or Scripts to copy the data
> Steps will varry based on the situation.
> Thanks
> Hari
>
> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote i
n
> message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
>
>|||Note that RESTORE VERIFYONLY doesn't do a "true" verification unless you are
on 2005 and did the
backup using CHECKSUM option. In such cases, you should do a real restore (i
nto a new database, of
course; possibly on another server).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in
message
news:66EFEFEC-3A63-4F14-A955-C27DC137EA94@.microsoft.com...[vbcol=seagreen]
> Thanks Hari
> "Hari Prasad" wrote:
>|||Exactly, I agree with Tibor.
Khwaja ,
As a practice for critical databases you could restore the backup once in a
while and do a DBCC CHECKDB and confirm that ur backupis good.
Thanks
Hari
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%230FiC3aUHHA.4076@.TK2MSFTNGP05.phx.gbl...
> Note that RESTORE VERIFYONLY doesn't do a "true" verification unless you
> are on 2005 and did the backup using CHECKSUM option. In such cases, you
> should do a real restore (into a new database, of course; possibly on
> another server).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote
> in message news:66EFEFEC-3A63-4F14-A955-C27DC137EA94@.microsoft.com...
>

How to find currpted backup file

1.How can i find out whether the backup file is currpted or good enough to
restore.
2.Is there any other ways to restore db without loosing any data when my
database files (mdf & Ldf) and my backup file is currupt
Thanks
Hello,
1.How can i find out whether the backup file is currpted or good enough to
restore.
RESTORE VERIFY ONLY
2. Is there any other ways to restore db without loosing any data when my
database files (mdf & Ldf) and my backup file is currupt
If both MDF and LDF is corrupted. You cant do much. Only way is to
restore from good backup. Incase if ur LDF is giving issues or if u have 803
error you can
1. Create a database with same
2. Stop SQL Server and copy the corrupted MDF above the new MDF file
3. Start SQL Server
4. Datbaase will be marked suspect. Change the mode to EMergency
5, Using DTS or Scripts to copy the data
Steps will varry based on the situation.
Thanks
Hari
"Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in
message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
> 1.How can i find out whether the backup file is currpted or good enough to
> restore.
> 2.Is there any other ways to restore db without loosing any data when my
> database files (mdf & Ldf) and my backup file is currupt
> Thanks
|||Thanks Hari
"Hari Prasad" wrote:

> Hello,
> 1.How can i find out whether the backup file is currpted or good enough to
> restore.
> RESTORE VERIFY ONLY
> 2. Is there any other ways to restore db without loosing any data when my
> database files (mdf & Ldf) and my backup file is currupt
> If both MDF and LDF is corrupted. You cant do much. Only way is to
> restore from good backup. Incase if ur LDF is giving issues or if u have 803
> error you can
> 1. Create a database with same
> 2. Stop SQL Server and copy the corrupted MDF above the new MDF file
> 3. Start SQL Server
> 4. Datbaase will be marked suspect. Change the mode to EMergency
> 5, Using DTS or Scripts to copy the data
> Steps will varry based on the situation.
> Thanks
> Hari
>
> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in
> message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
>
>
|||Exactly, I agree with Tibor.
Khwaja ,
As a practice for critical databases you could restore the backup once in a
while and do a DBCC CHECKDB and confirm that ur backupis good.
Thanks
Hari
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%230FiC3aUHHA.4076@.TK2MSFTNGP05.phx.gbl...
> Note that RESTORE VERIFYONLY doesn't do a "true" verification unless you
> are on 2005 and did the backup using CHECKSUM option. In such cases, you
> should do a real restore (into a new database, of course; possibly on
> another server).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote
> in message news:66EFEFEC-3A63-4F14-A955-C27DC137EA94@.microsoft.com...
>

How to find currpted backup file

1.How can i find out whether the backup file is currpted or good enough to
restore.
2.Is there any other ways to restore db without loosing any data when my
database files (mdf & Ldf) and my backup file is currupt
ThanksHello,
1.How can i find out whether the backup file is currpted or good enough to
restore.
RESTORE VERIFY ONLY
2. Is there any other ways to restore db without loosing any data when my
database files (mdf & Ldf) and my backup file is currupt
If both MDF and LDF is corrupted. You cant do much. Only way is to
restore from good backup. Incase if ur LDF is giving issues or if u have 803
error you can
1. Create a database with same
2. Stop SQL Server and copy the corrupted MDF above the new MDF file
3. Start SQL Server
4. Datbaase will be marked suspect. Change the mode to EMergency
5, Using DTS or Scripts to copy the data
Steps will varry based on the situation.
Thanks
Hari
"Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in
message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
> 1.How can i find out whether the backup file is currpted or good enough to
> restore.
> 2.Is there any other ways to restore db without loosing any data when my
> database files (mdf & Ldf) and my backup file is currupt
> Thanks|||Thanks Hari
"Hari Prasad" wrote:
> Hello,
> 1.How can i find out whether the backup file is currpted or good enough to
> restore.
> RESTORE VERIFY ONLY
> 2. Is there any other ways to restore db without loosing any data when my
> database files (mdf & Ldf) and my backup file is currupt
> If both MDF and LDF is corrupted. You cant do much. Only way is to
> restore from good backup. Incase if ur LDF is giving issues or if u have 803
> error you can
> 1. Create a database with same
> 2. Stop SQL Server and copy the corrupted MDF above the new MDF file
> 3. Start SQL Server
> 4. Datbaase will be marked suspect. Change the mode to EMergency
> 5, Using DTS or Scripts to copy the data
> Steps will varry based on the situation.
> Thanks
> Hari
>
> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in
> message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
> > 1.How can i find out whether the backup file is currpted or good enough to
> > restore.
> > 2.Is there any other ways to restore db without loosing any data when my
> > database files (mdf & Ldf) and my backup file is currupt
> > Thanks
>
>|||Note that RESTORE VERIFYONLY doesn't do a "true" verification unless you are on 2005 and did the
backup using CHECKSUM option. In such cases, you should do a real restore (into a new database, of
course; possibly on another server).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in message
news:66EFEFEC-3A63-4F14-A955-C27DC137EA94@.microsoft.com...
> Thanks Hari
> "Hari Prasad" wrote:
>> Hello,
>> 1.How can i find out whether the backup file is currpted or good enough to
>> restore.
>> RESTORE VERIFY ONLY
>> 2. Is there any other ways to restore db without loosing any data when my
>> database files (mdf & Ldf) and my backup file is currupt
>> If both MDF and LDF is corrupted. You cant do much. Only way is to
>> restore from good backup. Incase if ur LDF is giving issues or if u have 803
>> error you can
>> 1. Create a database with same
>> 2. Stop SQL Server and copy the corrupted MDF above the new MDF file
>> 3. Start SQL Server
>> 4. Datbaase will be marked suspect. Change the mode to EMergency
>> 5, Using DTS or Scripts to copy the data
>> Steps will varry based on the situation.
>> Thanks
>> Hari
>>
>> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote in
>> message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
>> > 1.How can i find out whether the backup file is currpted or good enough to
>> > restore.
>> > 2.Is there any other ways to restore db without loosing any data when my
>> > database files (mdf & Ldf) and my backup file is currupt
>> > Thanks
>>|||Exactly, I agree with Tibor.
Khwaja ,
As a practice for critical databases you could restore the backup once in a
while and do a DBCC CHECKDB and confirm that ur backupis good.
Thanks
Hari
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%230FiC3aUHHA.4076@.TK2MSFTNGP05.phx.gbl...
> Note that RESTORE VERIFYONLY doesn't do a "true" verification unless you
> are on 2005 and did the backup using CHECKSUM option. In such cases, you
> should do a real restore (into a new database, of course; possibly on
> another server).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote
> in message news:66EFEFEC-3A63-4F14-A955-C27DC137EA94@.microsoft.com...
>> Thanks Hari
>> "Hari Prasad" wrote:
>> Hello,
>> 1.How can i find out whether the backup file is currpted or good enough
>> to
>> restore.
>> RESTORE VERIFY ONLY
>> 2. Is there any other ways to restore db without loosing any data when
>> my
>> database files (mdf & Ldf) and my backup file is currupt
>> If both MDF and LDF is corrupted. You cant do much. Only way is to
>> restore from good backup. Incase if ur LDF is giving issues or if u have
>> 803
>> error you can
>> 1. Create a database with same
>> 2. Stop SQL Server and copy the corrupted MDF above the new MDF file
>> 3. Start SQL Server
>> 4. Datbaase will be marked suspect. Change the mode to EMergency
>> 5, Using DTS or Scripts to copy the data
>> Steps will varry based on the situation.
>> Thanks
>> Hari
>>
>> "Khwaja Arshaduddin" <KhwajaArshaduddin@.discussions.microsoft.com> wrote
>> in
>> message news:E5825040-0628-4821-8645-A5C833BDB601@.microsoft.com...
>> > 1.How can i find out whether the backup file is currpted or good
>> > enough to
>> > restore.
>> > 2.Is there any other ways to restore db without loosing any data when
>> > my
>> > database files (mdf & Ldf) and my backup file is currupt
>> > Thanks
>>
>

How to find current memory usage using SQL?

Anybody knows of any DBCC command or sp_configure param
which would tell me how much memory is SQL Server
currently grabbing?
I don't want to use DBCC perfmon(lrustats) because (1) it
is being deprecated and (b) the output is voluminous.
Using performance monitors is not an option since I want
to be able to do this from within a SQL script.
Thx a bunch!Check out master..sysperfinfo. The values in this table are not completely
cooked. Check out msdb..sp_sqlagent_get_perf_counters to see how the counter
values can be cooked.
--
Linchi Shea
linchi_shea@.NOSPAMml.com
"Asim" <aabubba@.yahoo.com> wrote in message
news:1fc7001c38a3b$4f2fc4a0$a601280a@.phx.gbl...
> Anybody knows of any DBCC command or sp_configure param
> which would tell me how much memory is SQL Server
> currently grabbing?
> I don't want to use DBCC perfmon(lrustats) because (1) it
> is being deprecated and (b) the output is voluminous.
> Using performance monitors is not an option since I want
> to be able to do this from within a SQL script.
> Thx a bunch!

How to find current isolation level in QA session ?

How to find current isolation level in QA session ?DBCC USEROPTIONS
If you didn't change it from read uncommitted, it seems like it is excluded from the result.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Hassan" <fatima_ja@.hotmail.com> wrote in message news:OmCUGAmsDHA.2464@.TK2MSFTNGP12.phx.gbl...
>|||Did you mean READ COMMITTED' It is omitted from the display unless you
explicitly set it to something.
--
HTH,
SriSamp
Please reply to the whole group only!
http://www32.brinkster.com/srisamp
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:u7H2bNmsDHA.424@.TK2MSFTNGP11.phx.gbl...
> DBCC USEROPTIONS
> If you didn't change it from read uncommitted, it seems like it is
excluded from the result.
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
news:OmCUGAmsDHA.2464@.TK2MSFTNGP12.phx.gbl...
> >
> >
>|||> Did you mean READ COMMITTED'
Oops. Yes, I did. Thanks for catching that.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"SriSamp" <ssampath@.sct.co.in> wrote in message news:u54S5jmsDHA.2400@.tk2msftngp13.phx.gbl...
> Did you mean READ COMMITTED' It is omitted from the display unless you
> explicitly set it to something.
> --
> HTH,
> SriSamp
> Please reply to the whole group only!
> http://www32.brinkster.com/srisamp
> "Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
> wrote in message news:u7H2bNmsDHA.424@.TK2MSFTNGP11.phx.gbl...
> > DBCC USEROPTIONS
> >
> > If you didn't change it from read uncommitted, it seems like it is
> excluded from the result.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > Archive at:
> http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
> >
> >
> > "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:OmCUGAmsDHA.2464@.TK2MSFTNGP12.phx.gbl...
> > >
> > >
> >
> >
>

How to find current database

Is there a way to find out what is the current database?
In Query analizer, you execute "use <db-name>", and you can se the current
database in the combo box. Is the an SQL command to find currrent database ?
Boaz Ben-Porat
Milestone SystemsSELECT DB_NAME()
"Boaz Ben-Porat" <bbp@.milestone.dk> wrote in message
news:%23UYynvt5FHA.1000@.tk2msftngp13.phx.gbl...
> Is there a way to find out what is the current database?
> In Query analizer, you execute "use <db-name>", and you can se the current
> database in the combo box. Is the an SQL command to find currrent database
> ?
> Boaz Ben-Porat
> Milestone Systems
>|||See function DN_NAME in BOL.
Example:
select db_name()
go
DB_NAME
http://msdn.microsoft.com/library/d...br />
706d.asp
AMB
"Boaz Ben-Porat" wrote:

> Is there a way to find out what is the current database?
> In Query analizer, you execute "use <db-name>", and you can se the current
> database in the combo box. Is the an SQL command to find currrent database
?
> Boaz Ben-Porat
> Milestone Systems
>
>|||Correction:
See function DB_NAME in BOL.
AMB
"Alejandro Mesa" wrote:
> See function DN_NAME in BOL.
> Example:
> select db_name()
> go
> DB_NAME
> http://msdn.microsoft.com/library/d... />
b_706d.asp
>
> AMB
> "Boaz Ben-Porat" wrote:
>

how to find conditions across rows (attendance)

Hello,
I need to find students that have 4 consecutive absences. When a
student is absent 4 times in a row, they can be dropped from the class.

My class attendance file contains each attendance by date and whether
they were present or not. When the student has 4 consecutive value 1
(absent) for a given session and a given class the are considered to be
dropped.
If I needed to know the total number of absences, I know I could group
and summarize, but this one has the consecutive twist.
Table:

CREATE TABLE "dbo"."clsatt"
("FULL_CLASS_ID" CHAR(15) NOT NULL,
"STUDENT_ID" CHAR(20) NULL,
"SESSION_ID" CHAR(10) NULL,
"MEETING" SMALLINT NOT NULL,
"PRESENT" CHAR(2) NOT NULL)
;
Present value of 1 is absent, value of 2 is present (3 means holiday)
Classes typically meet 12 times.
I would want something like
FULL_CLASS_ID, STUDENT_ID, SESSION_ID, 'Dropped'
as the output.

Notice in the example the first student was absent the last 4 meetings
The second student 5 absenses
and the third student was totally absent
In these three examples, they are flagged as dropped.
TIA
Rob
Inserts:

------------------------
insert into clsatt values ('BUS100','1675812194','200203',1,'2')
insert into clsatt values ('BUS100','1675812194','200203',2,'2')
insert into clsatt values ('BUS100','1675812194','200203',3,'2')
insert into clsatt values ('BUS100','1675812194','200203',4,'2')
insert into clsatt values ('BUS100','1675812194','200203',5,'2')
insert into clsatt values ('BUS100','1675812194','200203',6,'2')
insert into clsatt values ('BUS100','1675812194','200203',7,'2')
insert into clsatt values ('BUS100','1675812194','200203',8,'2')
insert into clsatt values ('BUS100','1675812194','200203',9,'1')
insert into clsatt values ('BUS100','1675812194','200203',10,'1')
insert into clsatt values ('BUS100','1675812194','200203',11,'1')
insert into clsatt values ('BUS100','1675812194','200203',12,'1')
insert into clsatt values ('BUS100','1712400537','200203',1,'2')
insert into clsatt values ('BUS100','1712400537','200203',2,'2')
insert into clsatt values ('BUS100','1712400537','200203',3,'2')
insert into clsatt values ('BUS100','1712400537','200203',4,'2')
insert into clsatt values ('BUS100','1712400537','200203',5,'2')
insert into clsatt values ('BUS100','1712400537','200203',6,'2')
insert into clsatt values ('BUS100','1712400537','200203',7,'2')
insert into clsatt values ('BUS100','1712400537','200203',8,'1')
insert into clsatt values ('BUS100','1712400537','200203',9,'1')
insert into clsatt values ('BUS100','1712400537','200203',10,'1')
insert into clsatt values ('BUS100','1712400537','200203',11,'1')
insert into clsatt values ('BUS100','1712400537','200203',12,'1')
insert into clsatt values ('BUS100','1801704805','200203',1,'1')
insert into clsatt values ('BUS100','1801704805','200203',2,'1')
insert into clsatt values ('BUS100','1801704805','200203',3,'1')
insert into clsatt values ('BUS100','1801704805','200203',4,'1')
insert into clsatt values ('BUS100','1801704805','200203',5,'1')
insert into clsatt values ('BUS100','1801704805','200203',6,'1')
insert into clsatt values ('BUS100','1801704805','200203',7,'1')
insert into clsatt values ('BUS100','1801704805','200203',8,'1')
insert into clsatt values ('BUS100','1801704805','200203',9,'1')
insert into clsatt values ('BUS100','1801704805','200203',10,'1')
insert into clsatt values ('BUS100','1801704805','200203',11,'1')
insert into clsatt values ('BUS100','1801704805','200203',12,'1')
insert into clsatt values ('BUS100','1922287588','200203',1,'1')
insert into clsatt values ('BUS100','1922287588','200203',2,'1')
insert into clsatt values ('BUS100','1922287588','200203',3,'2')
insert into clsatt values ('BUS100','1922287588','200203',4,'2')
insert into clsatt values ('BUS100','1922287588','200203',5,'2')
insert into clsatt values ('BUS100','1922287588','200203',6,'2')
insert into clsatt values ('BUS100','1922287588','200203',7,'2')
insert into clsatt values ('BUS100','1922287588','200203',8,'2')
insert into clsatt values ('BUS100','1922287588','200203',9,'2')
insert into clsatt values ('BUS100','1922287588','200203',10,'2')
insert into clsatt values ('BUS100','1922287588','200203',11,'1')
insert into clsatt values ('BUS100','1922287588','200203',12,'2')
insert into clsatt values ('BUS100','2188469657','200203',1,'1')
insert into clsatt values ('BUS100','2188469657','200203',2,'1')
insert into clsatt values ('BUS100','2188469657','200203',3,'2')
insert into clsatt values ('BUS100','2188469657','200203',4,'2')
insert into clsatt values ('BUS100','2188469657','200203',5,'2')
insert into clsatt values ('BUS100','2188469657','200203',6,'2')
insert into clsatt values ('BUS100','2188469657','200203',7,'2')
insert into clsatt values ('BUS100','2188469657','200203',8,'2')
insert into clsatt values ('BUS100','2188469657','200203',9,'1')
insert into clsatt values ('BUS100','2188469657','200203',10,'1')
insert into clsatt values ('BUS100','2188469657','200203',11,'1')
insert into clsatt values ('BUS100','2188469657','200203',12,'2')
insert into clsatt values ('BUS100','2515197431','200203',1,'1')
insert into clsatt values ('BUS100','2515197431','200203',2,'1')
insert into clsatt values ('BUS100','2515197431','200203',3,'2')
insert into clsatt values ('BUS100','2515197431','200203',4,'2')
insert into clsatt values ('BUS100','2515197431','200203',5,'1')
insert into clsatt values ('BUS100','2515197431','200203',6,'2')
insert into clsatt values ('BUS100','2515197431','200203',7,'2')
insert into clsatt values ('BUS100','2515197431','200203',8,'1')
insert into clsatt values ('BUS100','2515197431','200203',9,'2')
insert into clsatt values ('BUS100','2515197431','200203',10,'2')
insert into clsatt values ('BUS100','2515197431','200203',11,'1')
insert into clsatt values ('BUS100','2515197431','200203',12,'2')
select FULL_CLASS_ID,STUDENT_ID,SESSION_ID,'Dropped'
from (
select t1.FULL_CLASS_ID,
t1.STUDENT_ID,
t1.SESSION_ID,
t1.MEETING -
(select count(*) from clsatt t2
where t2.FULL_CLASS_ID=t1.FULL_CLASS_ID
and t2.STUDENT_ID=t1.STUDENT_ID
and t2.SESSION_ID=t1.SESSION_ID
and t2.MEETING<=t1.MEETING
and t2.PRESENT='1') as Rn
from clsatt t1
where t1.PRESENT='1') X
group by FULL_CLASS_ID,STUDENT_ID,SESSION_ID,Rn
having count(*)>= 4|||Mark,
Thanks much!
Rob|||I need to find students that have 4 consecutive absences. When a
student is absent 4 times in a row, they can be dropped from the class.

My class attendance file contains each attendance by date and whether
they were present or not. When the student has 4 consecutive value 1
(absent) for a given session and a given class the are considered to be
dropped.
If I needed to know the total number of absences, I know I could group
and summarize, but this one has the consecutive twist.
Table:

The tabel made no sense. NULL student ids of 20 characters in length?
Numeric attendance codes kept in CHAR(), you have no key? etc.

CREATE TABLE ClassAttendance
(class_name CHAR(15) NOT NULL,
student_id CHAR(20) NOT NULL,
session_id CHAR(10) NOT NULL,
meeting_nbr INTEGER NOT NULL,
attend_code INTEGER DEFAULT 1 NOT NULL
CHECK (attend_code IN (1,2,3)),
PRIMARY KEY (class_name, student_id, session_id, meeting_nbr));

Here is a shot using the new OLAP functions:

SELECT DISTINCT student_id, class_name, session_id
FROM (SELECT student_id, class_name, session_id,
SUM(attend_code)
OVER(PARTITION BY class_name, session_id
ORDER BY student_id, class_name, session_id
ROWS 4 PRECEDING)
FROM ClassAttendance
GROUP BY student_id, class_name, session_id)
AS X (student_id, class_name, session_id, last_four)
WHERE last_four = 4;|||thanks for your input Celko.

The table is only representative as to help me with the SQL, it is not
my student dimension as it is stored in my data warehouse.
The attendance code (PRESENT in my example) is an ID or attribute of
the attendance and not a fact. Therefore it is intended to be a char
type (or varchar). Summing on this field wont make sense from the
business. The only non-char type fields I keep are facts that can be
aggregated (tuition charges, payments and so forth).
Since this is a data warehouse intended to incorporate data from our
current operational systems as well as future currently unknown
systems, I need the flexibility that char provides. Another system
might have alpha-numeric student ID's.
I use DataManager from Cognos to build my warehouse, which has PK
information, so I have not defined in the database PKs (yet).
When I post for help, I don't expect to get exact SQL for my exact
problem; therefore I post what is representative of my problem. Also,
the solutions and ideas people post sometimes don't do what I need,
but provide me valuable knowledge to help solve future problems.
However in this case markc nailed it and I was able to solve my problem
and learn something new!
As for learning something new, I will try your example and see what it
does. Thanks for your input!
Thanks
Rob|||SQL Server 2005 doesn't support SUM()..OVER(ORDER BY..ROWS 4 PRECEDING)
However, you can do this

select FULL_CLASS_ID,STUDENT_ID,SESSION_ID,'Dropped'
from (
select FULL_CLASS_ID,
STUDENT_ID,
SESSION_ID,
MEETING - RANK() OVER(PARTITION BY
FULL_CLASS_ID,STUDENT_ID,SESSION_ID
ORDER BY MEETING) as Rn
from clsatt
where PRESENT='1') X
group by FULL_CLASS_ID,STUDENT_ID,SESSION_ID,Rn
having count(*)>= 4

Regards

Mark|||Anohter answer: Since there are only a few ranges, we can build an
auxiliary table and use it:

CREATE TABLE FourRanges
(start_session_nbr INTEGER NOT NULL,
end_session_nbr INTEGER NOT NULL,
CHECK (start_session_nbr < end_session_nbr));

INSERT INTO FourRanges VALUES (1, 4);
INSERT INTO FourRanges VALUES (2, 5);
INSERT INTO FourRanges VALUES (3, 6);
INSERT INTO FourRanges VALUES (4, 7);
..
INSERT INTO FourRanges VALUES (9, 12);

SELECT A1.course_name, A1.session_id, A1.student_id,
SUM(attend_code)
FROM ClassAttendance AS A1, FourRanges AS F
WHERE A1.session_nbr BETWEEN F.start_session_nbr
AND F.end_session_nbr
GROUP BY course_name, session_id, student_id
HAVING SUM(attend_code) = 4;

How to find cause of time-outs?

I am getting some .NET application exceptions saying the request to SQL
Server 2005 timed out. It is not always the same procedures that time out.
It is also very intermittent. How can I find out which SQL tasks are
running slow or to blame? I don't know where to look, what to log, etc.
.NET can't tell me more from its end.You could start by taking a look at this article on how to monitor
blocking.
http://support.microsoft.com/default.aspx?scid=kb;en-us;271509.

How to find cause of time-outs?

I am getting some .NET application exceptions saying the request to SQL
Server 2005 timed out. It is not always the same procedures that time out.
It is also very intermittent. How can I find out which SQL tasks are
running slow or to blame? I don't know where to look, what to log, etc.
.NET can't tell me more from its end.You could start by taking a look at this article on how to monitor
blocking.
http://support.microsoft.com/defaul...b;en-us;271509.

How to find Carriage Return CHAR(13)?

I've been looking for this online and on MSDN but no luck. I simply want to find all my CR in specific columns and later Replace them with a string (ie. --THIS-IS-A-CR--). The problem is I cannot even find/search CHAR(13) by using variations of the query below.

SELECT *
FROM Incident
WHERE (description LIKE '%CHAR(13)%') --I know this is incorrect

try this

SELECT *

FROM Incident

WHERE (description LIKE '%'+char(13)+'%')

|||Thanks Gopi, hope this post helps others as well|||

Gopi,

how will I replace with a string?

|||

This is what I am trying, it says that all rows have been updated, but when I do a find for the string I cannot find any changes to the table.

update Incident set
description = replace(cast(description AS varchar(8000)), '%'+char(13)+'%', '--THIS-WAS-CR--')
where description like '%'+char(13)+'%'

|||

try this

update Incident set

description = replace(cast(description AS varchar(8000)), char(13), '--THIS-WAS-CR--')

How to find calls to a stored procedure?

Hi folks,
One recurring problem we have is where to find calls to a stored
procedure when that sp may have changed and calls to it need to be
updated.
I know you can see the dependancies by right-clicking on the sp in
enterprise manager but we have found that this is not reliable and does
not pick up all occuranaces.
Does anybody know of a tool or method other than scripting the entire
schema creation.
Chris> Does anybody know of a tool or method other than scripting the entire
> schema creation.
Not that I am aware of any other work arounds. sysdepends is mostly not
dependable for sure. So you might need to script it out and compare.
HTH,
Vinod Kumar
MCSE, DBA, MCAD, MCSD
http://www.extremeexperts.com
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
<chris-s@.mailcity.com> wrote in message
news:1109328369.430554.180420@.o13g2000cwo.googlegroups.com...
> Hi folks,
> One recurring problem we have is where to find calls to a stored
> procedure when that sp may have changed and calls to it need to be
> updated.
> I know you can see the dependancies by right-clicking on the sp in
> enterprise manager but we have found that this is not reliable and does
> not pick up all occuranaces.
> Does anybody know of a tool or method other than scripting the entire
> schema creation.
> Chris
>|||Not sure about Enterprise Manager, but Query Analyzer does this and I've
found it to be reliable.
Press [F8] to bring up the object browser, drill into the stored procedure
and there's a folder for all parameters and dependencies.
However...I would have thought that this would use the same functionality
as EM, so should be equally (un)reliable.
Other alternative is to script the DB.
Trivial to do in EM, open up in Notepad and simply do a text search.
Of course...this only shows intra-database dependencies...if these SPs are
called by external applications then you've got to search through the data
access classes of all these [or refer to the associated documentation :-) ]
Griff|||have a look at DB Ghost (http://www.dbghost.com) for a complete approach to
database change management. You may also wish to read a white paper on
automated database change management -
http://www.innovartis.co.uk/pdf/ In...Mgt.
pdf
"chris-s@.mailcity.com" wrote:

> Hi folks,
> One recurring problem we have is where to find calls to a stored
> procedure when that sp may have changed and calls to it need to be
> updated.
> I know you can see the dependancies by right-clicking on the sp in
> enterprise manager but we have found that this is not reliable and does
> not pick up all occuranaces.
> Does anybody know of a tool or method other than scripting the entire
> schema creation.
> Chris
>|||http://vyaskn.tripod.com/code/searc...cedure_code.txt
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
<chris-s@.mailcity.com> wrote in message
news:1109328369.430554.180420@.o13g2000cwo.googlegroups.com...
> Hi folks,
> One recurring problem we have is where to find calls to a stored
> procedure when that sp may have changed and calls to it need to be
> updated.
> I know you can see the dependancies by right-clicking on the sp in
> enterprise manager but we have found that this is not reliable and does
> not pick up all occuranaces.
> Does anybody know of a tool or method other than scripting the entire
> schema creation.
> Chris
>

how to find C# in the text

I am not able to find C# using full text search of SQL 2005 beta 2
also, is there a way to enable some special words for indexing, such as c++,
c#,
thanks
--xin chne
I can find it. It seems to be case sensitive for C#(ie it can't find c#),
and it is case insensitive for c++.
Here is my repro
Create database XIN
GO
use XIN
GO
create table XIN
(pk int not null identity constraint primarykey1 primary key,
charcol char(20))
go
create fulltext catalog XIN as default
create fulltext index on XIN
(charcol) KEY INDEX primarykey1
insert into XIN (charcol) values('test')
insert into XIN (charcol) values('c')
insert into XIN (charcol) values('c++')
insert into XIN (charcol) values('c#')
insert into XIN (charcol) values('C')
insert into XIN (charcol) values('C++')
insert into XIN (charcol) values('C#')
select * from XIN where contains(*,'c') -- nothing
select * from XIN where contains(*,'c++') -- c++ and C++ returned
select * from XIN where contains(*,'c#') -- nothing
select * from XIN where contains(*,'C') -- nothing
select * from XIN where contains(*,'C++')-- c++ and C++ returned
select * from XIN where contains(*,'C#')--C# returned
--trying neutral
select * from XIN where contains(*,'c', language 0) -- nothing
select * from XIN where contains(*,'c++', language 0) -- c++ and C++
returned
select * from XIN where contains(*,'c#', language 0) -- nothing
select * from XIN where contains(*,'C', language 0) -- nothing
select * from XIN where contains(*,'C++', language 0)-- c++ and C++ returned
select * from XIN where contains(*,'C#', language 0) --C# returned
--removing c from the noise word list and rebuilding the index
select * from XIN where contains(*,'c') -- nothing
select * from XIN where contains(*,'c++') -- c++ and C++ returned
select * from XIN where contains(*,'c#') -- nothing
select * from XIN where contains(*,'C') -- nothing
select * from XIN where contains(*,'C++')-- c++ and C++ returned
select * from XIN where contains(*,'C#')--C# returned
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Xin Chen" <xchen@.xtremework.com> wrote in message
news:%23P3a9wWUFHA.628@.TK2MSFTNGP09.phx.gbl...
> I am not able to find C# using full text search of SQL 2005 beta 2
> also, is there a way to enable some special words for indexing, such as
c++,
> c#,
> thanks
> --xin chne
>

How to find binding errors to views

I have a view with no table present such as
Create table T1
(Col1 int)
go
Create view V1
as
select * from T1
go
drop table T1
go
select * from V1
I want to be able to run a query against a database that would give me all
the views that are inconsistent as above
I tried dbcc checkdb and dbcc checktable and it doesnt seem to work..I don't think there is a single way to get the list of all the views with
binding errors. Perhaps, one option is to execute sp_refreshview in a
cursor/loop which will error out.
If this is something you'd want to preserve for any future views, perhaps
you should consider using explicit column names in SELECT clauses, two part
naming in FROM clauses and WITH SCHEMABINDING option while creating the
view.
Anith|||I tried the cursor approach but the cursor aborts after it finds the first
violation. How can I let it continue ?
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eHi%23IVnjFHA.2444@.TK2MSFTNGP10.phx.gbl...
> I don't think there is a single way to get the list of all the views with
> binding errors. Perhaps, one option is to execute sp_refreshview in a
> cursor/loop which will error out.
> If this is something you'd want to preserve for any future views, perhaps
> you should consider using explicit column names in SELECT clauses, two
part
> naming in FROM clauses and WITH SCHEMABINDING option while creating the
> view.
> --
> Anith
>|||I do a build of the database using the source code using DB Ghost Database
Builder. That way all errors are quickly reported and can therefore be fixed
.
The builder builds objects at around 1000/minute making this a very quick an
d
extremely thorough process.
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Hassan" wrote:

> I have a view with no table present such as
> Create table T1
> (Col1 int)
> go
> Create view V1
> as
> select * from T1
> go
> drop table T1
> go
> select * from V1
> I want to be able to run a query against a database that would give me all
> the views that are inconsistent as above
> I tried dbcc checkdb and dbcc checktable and it doesnt seem to work..
>
>

How to find binding errors to views

I have a view with no table present such as
Create table T1
(Col1 int)
go
Create view V1
as
select * from T1
go
drop table T1
go
select * from V1
I want to be able to run a query against a database that would give me all
the views that are inconsistent as above
I tried dbcc checkdb and dbcc checktable and it doesnt seem to work..I don't think there is a single way to get the list of all the views with
binding errors. Perhaps, one option is to execute sp_refreshview in a
cursor/loop which will error out.
If this is something you'd want to preserve for any future views, perhaps
you should consider using explicit column names in SELECT clauses, two part
naming in FROM clauses and WITH SCHEMABINDING option while creating the
view.
Anith|||I tried the cursor approach but the cursor aborts after it finds the first
violation. How can I let it continue ?
"Anith Sen" <anith@.bizdatasolutions.com> wrote in message
news:eHi%23IVnjFHA.2444@.TK2MSFTNGP10.phx.gbl...
> I don't think there is a single way to get the list of all the views with
> binding errors. Perhaps, one option is to execute sp_refreshview in a
> cursor/loop which will error out.
> If this is something you'd want to preserve for any future views, perhaps
> you should consider using explicit column names in SELECT clauses, two
part
> naming in FROM clauses and WITH SCHEMABINDING option while creating the
> view.
> --
> Anith
>|||I do a build of the database using the source code using DB Ghost Database
Builder. That way all errors are quickly reported and can therefore be fixed
.
The builder builds objects at around 1000/minute making this a very quick an
d
extremely thorough process.
regards,
Mark Baekdal
http://www.dbghost.com
http://www.innovartis.co.uk
+44 (0)208 241 1762
Build, Comparison and Synchronization from Source Control = Database change
management for SQL Server
"Hassan" wrote:

> I have a view with no table present such as
> Create table T1
> (Col1 int)
> go
> Create view V1
> as
> select * from T1
> go
> drop table T1
> go
> select * from V1
> I want to be able to run a query against a database that would give me all
> the views that are inconsistent as above
> I tried dbcc checkdb and dbcc checktable and it doesnt seem to work..
>
>