Need Return Valre From &<&<restore Filelistonly From Backupdevice&>&>

Jul 21, 2003

When moving around 800 databases from 40 MSDE servers to on STD SQL2k server,
I need the logicalfile name info in order to run the script to restore from backup device. The only place I could get from the target server is the backup device(which are copied from 40 MSDE to STD). It works fine and retuns value from "restore filelistonly from backup_Testing".

But fails when I tried to put the result into a table variable or a temp #Table.

declare @tableFileList
table (LogicalName nvarchar(128), PhysicalName nvarchar(260), Type char(1), FileGroupName nvarchar(128), Size numeric(20,0), MaxSize numeric(20,0))

insert into @tableFileList
restore filelistonly from backup_Testing

Server: Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'restore'.

thanks
David

View 8 Replies


ADVERTISEMENT

Syntex For Restore Filelistonly &&amp; Restore Verifyonly

Jun 30, 2006

Hello,

Would some one please help me with the syntex on how to run "restore filelistonly" or restore verifyonly" on a SQL backup which has multiple filesets?? My backups locations are as follow:
RESTORE VERIFYONLY
From disk = 'E:syndicated_databank__bkup_01.bak',
'E:syndicated_databank__bkup_02.bak',
€˜E:syndicated_databank__bkup_03.bak€™,
€˜E:syndicated_databank__bkup_04.bak€™, €˜E:syndicated_databank__bkup_05.bak€™

I tried to do a restore with the above, I got error The label 'E' has already been declared. Label names must be unique within a query batch or stored procedure.

Please advise!!

View 3 Replies View Related

Restore Filelistonly In Sp -- How?

Feb 25, 2000

I would like to use "RESTORE FILELISTONLY' in a stored procedure, but I do not know how to retrieve the result set that it makes up. I need to know the names of files contained in the backup set, so I can do a specific restore.

Thanks,
Judith

View 4 Replies View Related

Error Message 3624 Restore Filelistonly

Jan 20, 2005

When I try to do a restore filelistonly I get the following message

[Server: Msg 3624, Level 20, State 1, Line 1

Location: upgraddb.cpp:214
Expression: tableIndex < ARRAY_LEN (upgradeMap)
SPID: 8
Process ID: 216]

I get the same when I try a restore database
The instance is on a xp Pro local desktop which is only new. No database has been restored yet on this instance.
But everything seems to work fine on this instance e.g Northwind, xp_cmdshell etc.
Any help??
Thanks

View 2 Replies View Related

Filelistonly

Aug 13, 2007

1-anyone know why there are 4 files in this bak file?
2-how do you create it?
3-how do you restore it?
thx



restore filelistonly
from disk = 'r:ackupIPGDB_BackupDevice.bak'



PRIMARYD:Program FilesMicrosoft SQL ServerMSSQLDataklxprodplanklxprodplan.mdfDPRIMARY5242880035184372080640
KLX_BASE_DATD:Program FilesMicrosoft SQL ServerMSSQLDataklxprodplanklxprodplan_1.mdfDKLX_BASE_DAT172772556835184372080640
KLX_DERIVED_DATD:Program FilesMicrosoft SQL ServerMSSQLDataklxprodplanklxprodplan_2.mdfDKLX_DERIVED_DAT7112294400035184372080640
LOGL:Program FilesMicrosoft SQL ServerMSSQLLogsklxprodplanklxprodplan_log.ldfLNULL164587110435184372080640


=============================
http://www.sqlserverstudy.com

View 9 Replies View Related

Filelistonly Vs Verifyonly

Jul 23, 2005

Hello all. Does anyone know if a successful completion of a 'restorefilelistonly' command would indicate that a backup file is valid? I'venoticed some of our backup jobs failing during the verify phase of themaintenenace plan because of network issues, and I'd like a quick way tocheck if the backup is valid because some of the backup files take hours toverify. I searched MS Support and they don't seem to have any info on this.TW

View 1 Replies View Related

Error Retriving Backup Filelistonly

Jan 28, 2008

Hi Guys.

i have write a store procedure which take few input and then backup the database and at the same time it's restore the database with new name, but i m hving a error code.
what this program do in restore section, it's read the backup file and all give me list of all the file with the location and then i can rename them.
actually the purpose of doing this is to create a new database on behalf of old database. plz have alook code
PLZ, PLZ help me, it's really geting headach



USE [master]

GO

/****** Object: StoredProcedure [dbo].[CreateNewDB] Script Date: 01/28/2008 17:13:09 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER proc [dbo].[CreateNewDB]

@ActualDb varchar(128),

@dbname sysname ,

@recipients varchar(128)

AS

SET NOCOUNT ON

Declare @cmd sysname ,

@filename varchar(128) ,

@Backuppath varchar(1000),

@LogicalName varchar(2000),

@ActualPath varchar(2000),

@Aloop int,

@FileID int,

@sql nvarchar(4000)



SET @Backuppath = 'C:' + @dbname

-- TAKE BACKUP



BACKUP DATABASE @ActualDb TO DISK = @Backuppath WITH NOFORMAT, INIT, NAME = 'DBBackup-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10



-- Get files in backup

select @cmd = 'restore filelistonly from disk = ''' + @Backuppath + ''''

CREATE table #RestoreFileListOnly

(

LogicalName sysname,

PhysicalName sysname,

type char(1),

FileGroupName sysname,

[size] bigint,

[MaxSize] bigint,

FileID int

)

INSERT into #RestoreFileListOnly

exec(@cmd)

-- buld the restore command

set @Aloop=1

set @FileID=0

set @sql= ''

set @sql = @sql + 'RESTORE DATABASE ' + @dbname + CHAR(10)

set @sql = @sql + ' FROM DISK = ''' + @Backuppath + '''' + CHAR(10)

set @sql= @sql + ' WITH FILE = 1' + CHAR(10)

WHILE (@aloop <= @@ROWCOUNT)

BEGIN

SELECT @LogicalName = LogicalName , @FileID = FileID, @ActualPath = Left(PhysicalName, len(PhysicalName)-charindex('',reverse(PhysicalName))+1) FROM #RestoreFileListOnly WHERE FILEID > @FileID


SET @sql= @sql + ',' + CHAR(10)

SET @sql= @sql + CHAR(9) + 'MOVE''' + @LogicalName + '''TO''' + @ActualPath + '''' + @dbname + ''''

-- @sql= @sql + 'MOVE '''+ + '' TO N'C:Program FilesMicrosoft SQL ServerMSSQL.2MSSQLDATAMALIK.mdf'

SET @Aloop=@Aloop+1

END

SET @sql = @sql + ', NOUNLOAD, STATS = 10'

-- Restore the database

print @sql

EXEC (@sql)



Drop table #RestoreFileListOnly



-- send email to the define person.

EXEC master..xp_sendmail @subject = @cmd, @recipients = @recipients, @message = @@servername



ERROR:


Msg 213, Level 16, State 7, Line 1

Insert Error: Column name or number of supplied values does not match table definition.

Msg 3013, Level 16, State 1, Line 1

RESTORE FILELIST is terminating abnormally.

View 5 Replies View Related

Return Error Code (return Value) From A Stored Procedure Using A Sql Task

Feb 12, 2008


I have a package that I have been attempting to return a error code after the stored procedure executes, otherwise the package works great.

I call the stored procedure from a Execute SQL Task (execute Marketing_extract_history_load_test ?, ? OUTPUT)
The sql task rowset is set to NONE. It is a OLEB connection.

I have two parameters mapped:

tablename input varchar 0 (this variable is set earlier in a foreach loop) ADO.
returnvalue output long 1

I set the breakpoint and see the values change, but I have a OnFailure conditon set if it returns a failure. The failure is ignored and the package completes. No quite what I wanted.

The first part of the sp is below and I set the value @i and return.


CREATE procedure [dbo].[Marketing_extract_history_load_TEST]

@table_name varchar(200),

@i int output

as

Why is it not capturing and setting the error and execute my OnFailure code? I have tried setting one of my parameter mappings to returnvalue with no success.

View 2 Replies View Related

How To Return SqlDataReader And Return Value (page Count) From SPROC

Jan 2, 2006

This is my function, it returns SQLDataReader to DATALIST control. How
to return page number with the SQLDataReader set ? sql server 2005,
asp.net 2.0

    Function get_all_events() As SqlDataReader
        Dim myConnection As New
SqlConnection(ConfigurationManager.AppSettings("..........."))
        Dim myCommand As New SqlCommand("EVENTS_LIST_BY_REGION_ALL", myConnection)
        myCommand.CommandType = CommandType.StoredProcedure

        Dim parameterState As New SqlParameter("@State", SqlDbType.VarChar, 2)
        parameterState.Value = Request.Params("State")
        myCommand.Parameters.Add(parameterState)

        Dim parameterPagesize As New SqlParameter("@pagesize", SqlDbType.Int, 4)
        parameterPagesize.Value = 20
        myCommand.Parameters.Add(parameterPagesize)

        Dim parameterPagenum As New SqlParameter("@pageNum", SqlDbType.Int, 4)
        parameterPagenum.Value = pn1.SelectedPage
        myCommand.Parameters.Add(parameterPagenum)

        Dim parameterPageCount As New SqlParameter("@pagecount", SqlDbType.Int, 4)
        parameterPageCount.Direction = ParameterDirection.ReturnValue
        myCommand.Parameters.Add(parameterPageCount)

        myConnection.Open()
        'myCommand.ExecuteReader(CommandBehavior.CloseConnection)
        'pages = CType(myCommand.Parameters("@pagecount").Value, Integer)
        Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    End Function

Variable Pages is global integer.

This is what i am calling
        DataList1.DataSource = get_all_events()
        DataList1.DataBind()

How to return records and also the return value of pagecount ? i tried many options, nothing work. Please help !!. I am struck

View 3 Replies View Related

'Return' Statement In A Function,Get,or Operator Must Return A Value....Question

Aug 28, 2007


I'm a Reporting Services New-Be.

I'm trying to create a report that's based on a SQL-2005 Stored Procedure.

I added the Report Designer, a Report dataset ( based on a shared datasource).

When I try to build the project in BIDS, I get an error. The error occurs three times, once for each parameter on the stored procedure.

I'll only reproduce one instance of the error for the sake of brevity.

[rsCompilerErrorInExpression] The Value expression for the query parameter 'UserID' contains an error : [BC30654] 'Return' statement in a Function, Get, or Operator must return a value.

I've searched on this error and it looks like it's a Visual Basic error :

http://msdn2.microsoft.com/en-us/library/8x403818(VS.80).aspx

My guess is that BIDS is creating some VB code behind the scenes for the report.

I can't find any other information that seems to fit this error.

The other reports in the BIDS project built successfully before I added this report, so it must be something specific to the report.

BTW, the Stored Procedure this report is based on a global temp table. The other reports do not use temp tables.

Can anyone help ?

Thanks,

View 5 Replies View Related

Using Output Clause And Return Timestamp And Return Value

Oct 28, 2006

I am trying to bring my stored proc's into the 21st century with try catch and the output clause. In the past I have returned info like the new timestamp, the new identity (if an insert sproc), username with output params and a return value as well. I have checked if error is a concurrency violation(I check if @@rowcount is 0 and if so my return value is a special number.)

I have used the old goto method for trapping errors committing or rolling back the transaction.

Now I want to use the try,catch with transactions. This is easy enough but how do I do what I had done before?

I get an error returning the new timestamp in the Output clause (tstamp is my timestamp field -- so I am using inserted.tstamp).

Plus how do I check for concerrency error. Is it the same as before and if so would the check of @@rowcount be in the catch section?

So how to return timestamp and a return value and how to check for concurrency all in the try/catch.

by the way I read that you could not return an identity in the output clause but I had no problem.

Thanks for help on this

SM haig

View 5 Replies View Related

Reporting Services :: Cannot Click Restore Button In RS Configuration Manager To Restore Encryption Key

Oct 29, 2015

While migrating Report services in SQL Server 2005 to 2014, I am trying to restore the Encryption Key in RS Configuration Manager in2014. But I cannot click the 'Restore' button in RS Configuration Manager. So if I should be grant more right to do so or any other action?

View 2 Replies View Related

SQL Server Admin 2014 :: How To Do System Restore To Previous Restore Point

Dec 31, 2014

In Windows Server 2012. How do I do a System Restore to a previous restore point?I need to install the 64 bit and 32 bit Oracle Client Install for connections in SSIS and to create Oracle Linked Servers.

If you make a mistake it is not fun removing it. Sometimes it corrupts the machine and it is difficult to uninstall since there is not an Oracle Universal installer for Oracle 11g.If you install the 32 bit before the 64 you mess up the machine.how to create a restore point.

View 6 Replies View Related

Transact SQL :: Backup / Restore Tools Which Can Restore Multiple Environments

Jun 25, 2015

I am looking for a SQL Backup/Restore tools which can restore multiple environments.  Here is high level requirements.

1.  We have 4 DBs, range from 1 TB - 1.5 TB Each Database.  When we restore to QA, DEV, or Staging, we usually restore 4 of them.
2.  I am looking for the speed to complete restoring between 1 - 2 hours for 4 DBs.

I am evaluating the Dephix Software but the setup is very complex and its given us a lot of issues with Windows Authentions, and failure in the middle of the backup.  I used Guess Software many years ago but can't find it on the web site any more. Speed is very important for us mean complete restoring as fast as possible.  We are on SQL 2012 and SQL 2008 R2.We are currently using NETAPP Technology and I have Redgate Backup Tool but I am mainly looking for fast Restore Process.

View 4 Replies View Related

Why SP Return SQLException When No Data Return ?

Jul 24, 2006

hi, good day,

i have using BCP to output SP return data into txt file, however, when it return nothing , it give SQLException like "no rows affected" , i have try to find out the solution , which include put "SET NOCOUNT ON" command before select statement, but it doesn't help :(

anyone know how to handle the problem when SP return no data ?

thanks in advance

View 1 Replies View Related

Database Restore Failed, Now Inaccessible And Can Not Restore.

Apr 27, 2007

I have seen this before. A 2000 restore fails, leaving the database thinking it is being restored but the restore job failed and errors when it is restarted. EM is clueless. I believe there is a proc to reset some flag. Can you share it with me???



Thanks!

View 4 Replies View Related

Transact SQL :: Return Set Of Values From SELECT As One Of Return Values From Stored Procedure

Aug 19, 2015

I have a stored procedure that selects the unique Name of an item from one table. 

SELECT DISTINCT ChainName from Chains

For each ChainName, there exists 0 or more StoreNames in the Stores. I want to return the result of this select as the second field in each row of the result set.

SELECT DISTINCT StoreName FROM Stores WHERE Stores.ChainName = ChainName

Each row of the result set returned by the stored procedure would contain:

ChainName, Array of StoreNames (or comma separated strings or whatever)

How can I code a stored procedure to do this?

View 17 Replies View Related

SQL 2012 :: Restore DB From Prod To Test - How To Restore Users In Test

Jun 25, 2015

I need to restore test DB from production backup but once it is restored I would need all the permissions of sql logins and windows AD account intact in test Db as it was before.

View 4 Replies View Related

RESTORE Database - Database In Use, Restore Fails

Nov 19, 1999

11/19

Trying to keep out sysadmins & sa during/between database RESTORE

Configuration:
WINNT Server Enterprise 4.0 w/SP5
SQL Server 7 Enterprise & SP1

2 SQL Servers:
Production Server
Standby server

I Backup (full backup) databases to disk on primary server (logical backup devices are physicaly located on a Standby server (dedicated gigabit NIC in each server for this process). Transaction logs are applied to the Standby server throughout the day.

Problem:
How to keep out "sa" and sysadmins from a database while I'm restoring (or between restores) to a standby server?
The database being restored cannot be in use during a restore.
If a DBA forgets that this process is happening, the statement fails (RESTORE)for the database they happen to be in at the time of the restore.

Example restore statement:
Standby Server -
RESTORE DATABASE databasename FROM database_dd WITH DBO_ONLY, REPLACE, STANDBY = 'g:Mssql7FromPrimaryDatabaseName_undo.ldf'

I could restrict Domain sysadmin access and change sa password. I could also put the database in "Single user" mode, however this could become problem if my process disconnects and then someone else connects - then my process is locked out. What I'm really looking for is to lock out all activity for a database that is in "standby mode" except for RESTORE processes.

Any ideas??

Wade
wadej@vailresorts.com

View 1 Replies View Related

Return Value From SP

Dec 6, 2006

I have the following SP
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE spGetResettedPassword@Email nvarchar(50)ASBEGIN SET NOCOUNT ON; declare @newid uniqueidentifier set @newid=newid() declare @newPass nvarchar(10) set @newPass=convert(nvarchar(100),@newid) set @newPass=substring(@newPass,1,7) UPDATE aspnet_Membership SET Password=@newPass WHERE Email=@Email return @newPassENDGO
When  calling it from code like this:            MyConnection.Open()            cmd = New SqlCommand("spGetResettedPassword", MyConnection)            cmd.CommandType = Data.CommandType.StoredProcedure            myTrans = MyConnection.BeginTransaction()            cmd.Transaction = myTrans            fBeginTransCalled = True            bSuccess = False            cmd.Parameters.Add(New SqlParameter("@Email", Email))            Dim NewPassword As Object = cmd.ExecuteScalar            If NewPassword <> Nothing And CType(NewPassword, String) <> "" _            And TypeOf (NewPassword) Is String Then                Return CStr(NewPassword)            Else                Return "ERROR, CONTACT US ON THE SITE"            End If            bSuccess = True            fBeginTransCalled = False
 
I get the following error:
Conversion failed when converting the nvarchar value '40DC5F3' to data type int.
What is happening here?!?!

View 1 Replies View Related

Return Value From SQL

Jun 14, 2008

I am trying to get the following to work, here is the stored procedureSTORED PROCEDURE (@varA varchar(25),@varb varchar(25))AS IF EXISTS (SELECT column1 FROM table1 WHERE nameA=@NameA)RETURN 01IF EXISTS (SELECT column2 FROM table1 WHERE nameB=@nameB)RETURN 02ELSE     BEGIN              INSERT INTO table1 (nameA, NameB)              VALUES (@nameA, @nameB)          RETURN 03     END ****************************************************************************                 dim cn as New sqlConnection(connectionstring)                 dim cm as sqlcommand            cn.Open()            With Cm                .CommandType = CommandType.StoredProcedure                .CommandText = "STOREDPROCEDURE"                .Connection = cn            End With            'INSERT Names            Cm.Parameters.Add("@nameA", SqlDbType.VarChar, 25).Value = nameA.text            Cm.Parameters.Add("@nameB", SqlDbType.VarChar, 25).Value = nameB.text            param_returnValue = Cm.Parameters.Add("RETURN_VALUE", SqlDbType.Int)            param_returnValue.Direction = ParameterDirection.ReturnValue*******************************************************************************************This is where I get stuck. I need to display certain error messages depending on the return value.*******************************************************************************************            dim insertStatus as integer            insertStatus = Cm.ExecuteScalar()            If insertStatus = 01 Then                warningLabel.Text = "NameA AlreadyExists."                If insertStatus = 02 Then                    warningLabel.Text = "NameA AlreadyExists."                    If insertStatus = 9999 Then                        Response.Redirect("success.aspx")                    End If                End If            End If I am pretty sure the IF statements arent the way to go especially because it is not working but i am curious to how I am to make this work.

View 2 Replies View Related

Return

May 18, 2004

whats wrong with this SP? I want @id to contain the row identity of the newly created row as a return value.ALTER PROCEDURE setCountry
(
@name varchar( 50 ) = NULL,
@alt varchar( 24 ) = NULL,
@code varchar( 3 ) = NULL,
@id int = null OUT
)
AS
SET NOCOUNT ON
INSERT INTO Countries( CountryName, CountryAltName, CountryCode ) VALUES ( @name, @alt, @code )
@id = @@identity
RETURN

View 8 Replies View Related

If...Else Return Value

Oct 11, 2006

Hi,

Here is my sp:

Quote: CREATE PROCEDURE dbo.usp_ProfQuals_Add_AwardingBody_nr
(
@awardbody varchar(100)
)
AS
BEGIN
declare @message int

if EXISTS(SELECT vchr_awardingbody from tbl_ProfQuals_AwardingBody where vchr_awardingbody = @awardbody)
set @message = 1
else
set @message = 2
insert into tbl_ProfQuals_AwardingBody (vchr_AwardingBody) values (@awardbody)

END
return @message

The problem I am having is that it returns the correct value if there is a record that exists or indeed if it doesn't BUT ... even when a record exists it still carries out the insert!

Any help much appreciated.

Dave

View 3 Replies View Related

How Could I Return The Next Row(Or 8th Row For Example)

Sep 25, 2005

Hi,
I want to return the next row in a select ... order by ... cursor.
I don't want to loop,just SQL,Do you know any solution?
For example: in Oracle we use rownum,is there any equivalent in SQL Server?
-Thanks

View 8 Replies View Related

Getting The Return Value

Aug 15, 2007

Hello everyone -

Please advise on why the output value is an empty

declare
@DynamicSQL3 NVARCHAR(4000

SET @DynamicSQL3 = 'SELECT Security_Level_ID ' +
'FROM ' + @DatabaseName + '.dbo.Security_Level_Master ' +
'WHERE Security_Level_Name = ''Administrator'' '

exec sp_executesql @DynamicSQL3, N'@i int output', @AdministratorSecurityID output


I run the query and see the grid being populated with the proper
security_level_id in the query analyzer,

but when i execute a print @AdministratorSecurityID
there is a space character in the results window

please advise on what i am doing wrong

thanks
tony

View 2 Replies View Related

Return SUM That Is Not 0?

Oct 15, 2013

I have this table that contains transactions for a specific client and some clients, when I total the transactions, have a zero balance.

I want to be able to filter those clients out, only show the ones that have open balances.

Here's an example:

DECLARE @T1 TABLE( CODE VARCHAR(6), ITEM INTEGER, AMOUNT INTEGER)
INSERT INTO @T1
VALUES
('ABC',4001,110),
('ABC', 4001, -110),
('ABC',4002,-5.5),

[code]....

If you look at the table, client ABC has a lot of transactions but if I SUM them the balance is 0, same with client GHI. The only row that show show on my query is client DEF.

I am trying to do something like this:

select *
from @T1
having Code in ( SELECT code
from @T1
group by code
having SUM(amount) <> 0)

but I get an error.

View 3 Replies View Related

No Return Value

Mar 6, 2007

Hi all. How could i trigger the result in select statement? If the query does not return a value, there must be a prompt message to appear.

thanks
-Ron-

View 14 Replies View Related

Return The Last Row Only

Jul 5, 2007

Hello!

I'm new to SQL and i've searched everywhere for the answer to this question but I can't seem to find the anwer anywhere. My question is.....

If there are multiple rows for a specific field, is there a way in SQL to only return the last row based on that specific field.

For example, I wrote a query that returns a list of patients who have a specific lab type. If a patient has had several labs taken, they show up in the result set several times (for each lab date). I only want to return the most recent lab date.

Here is my query........

SELECT id, resulted_test_desc, result_value, units, update_date

FROM dbo.lab_result LEFT OUTER JOIN
dbo.mpi ON dbo.lab_result.blind_key = dbo.mpi.chart LEFT OUTER JOIN
dbo.mpi_xref ON dbo.mpi.chart = dbo.mpi_xref.blind_key

WHERE resulted_test_desc = 'Hemoglobin'

Any help would be greatly appreciated.

Thanks!

Amedeo

View 20 Replies View Related

How To Get A SP Return Value On Another SP?

Sep 12, 2006

I have a SP, which will exec other SP depend on the input.the "other SP" need to return a integer back.How to do this?Thanks for give me a hand.

View 4 Replies View Related

Return New Id

Jul 20, 2005

Dear All,I try this but it keeps returning zero !Dim newid As LongCurrentProject.Connection.Execute "INSERT INTO [ORDER] (ORD_P_ID,ORD_CREATION_DATE) VALUES ('4004', CONVERT(DATETIME,'" & Year(Date) & "-" &Month(Date) & "-" & Day(Date) & " 00:00:00', 102)); select @@identity as'newID'"Me.RequeryMsgBox newid >> returns 0Msgbox DMax("ORD_ID","[ORDER]") >> returns the new idMy question stays: is it possible to return the newid into a VB-variabledirectly?Filip

View 1 Replies View Related

Return One Row

Jul 20, 2005

HelloI was wondering if someone could help me out with something.With the following rows:agnt_num supv_num meet_num strt_dt strt_lvl trm_dt trm_lvl1 1 1 10-10-2000 01 10-15-2000 021 1 2 10-09-2000 06 051 2 1 10-08-2000 05 10-20-2000 011 2 1 10-05-2000 01 10-15-2000 03What I need is SQL to get one row per agnt/supv with the following:strt_dt, strt_lvl of earliest strt_dttrm_dt, trm_lvl of the latest trm_dt but only if all trm_dts forthe supv arefilled in, otherwise null for bothagnt_num supv_num strt_dt strt_lvl trm_dt trm_lvl1 1 10-09-2000 06 null null1 2 10-05-2000 01 10-20-2000 01If anyone has any ideas on the most efficient way to accomplish this,I'd appreciate a reply.Thanks!

View 5 Replies View Related

How To Return Just Any One Row Among So Many?

Sep 19, 2007


I have set of procedures that implement business logic in such a way that I am just interested to return only one row when there could possibly be millions of them. Those procedures are in this form


SELECT Top 1 SGP.GroupID

FROM dbo.SubGroupPerm SGP

INNER JOIN dbo.GroupPermStats GPS on SGP.GroupID = GPS.GroupID

INNER JOIN dbo.IMISProduct IP on GPS.ProductID = IP.ProductID

INNER JOIN dbo.HasMeasureGroup HMG on SGP.GroupID = HMG.GroupID

WHERE SGP.SubscriberID = 40335

AND HMG.MeasureTypeID = 119

AND GPS.IndustryCode = 'CT'


Such tables are properly indexed and most queries return results using clustered index seek/index seek operations. Unfortunately, in presence of large tables I don't get the desired response time because query generates massive IOs. I was wondering if someone could possibly have another clever way to re-write above query where we just have to return one row?

View 17 Replies View Related

SP Return Value

Mar 14, 2008

in my package i am executing a stored procedure from execute sql task which is something like
DECLARE @return_value int
EXEC @return_value = [dbo].[NextDigitalDataLoad]
SELECT 'ReturnValue' = @return_value
GO

Now based on the value returned by this i have to check in a dataflow task whether the file content is correct or not.
please tell me how to do

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved