I have a series of SQL scripts that contain a mix of DDL and DML. Given the overall size of the scripts (7,000+ lines) I've chosen to split them into several different files (this also promotes different developers working on different pieces in Visual Source Safe).
When it comes time to run them, however, I want to run them all in a sequence -- without having to open, and run each one.
In "The Oracle" you could create a SQL-PLUS script like this:
@MyScript1.sql
@MyScript2.sql
Which would result in Script1 and Script2 being run, with the output going to a single log file.
There is a bug in SSIS2005 concerning the way that checkpoint files behave in concert with Sequence containers. It is documented (at length) here:
Is it possible to execute a container regardless of the checkpoint file? (http://forums.microsoft.com/msdn/showpost.aspx?postid=1574262&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=0)
Is anyone from Microsoft yet able to give a definitive answer to whether this will be fixed or not in Katmai? A yes or no answer would be very very much appreciated.
I proposed on a new server that we separate Data Files, Log Files, tempDB, Backups, etc. onto separate LUNS on a SAN with High Speed Solid State Drives.I was told that with the new technology with solid state SAN's that it would decrease performance and that it did not work the same way as it did when you had RAID 5's etc.I thought that if things were cared out correctly by a SAN Administrator they would know how to configure for optimal performance.
In the For Loop, How to Iterate from Older flat files to Newer flat files based on File's Timestamp. If there are some older files in that folder, it should be processed first and then continue with the newer one.
In the first step of my SSIS package I need to get files from FTP and dump it/them in a local directory, but it's more than that, the logic is like this: 1. If no file(s) found, stop executing and send email saying no file(s) found; 2. If file(s) found, then compare it/them with existing files in our archive folder; if file(s) already exist in archive folder, stop executing and send email saying file(s) already existed, if file(s) not in archive folder yet, then transfer it/them to the local directory for processing.
I know i have to use a script task to do this and i did some research and found examples for each of the above 2 steps and not both combined, so that's why I need some help here to get the logic incorporated right.
Thanks for the help in advance and i apologize for the long lines of code!
example for step 1: ----------------------------------------------------------------------------------------------------------
' Microsoft SQL Server Integration Services Script Task ' Write scripts using Microsoft Visual Basic ' The ScriptMain class is the entry point of the Script Task.
' The execution engine calls this method when the task executes. ' To access the object model, use the Dts object. Connections, variables, events, ' and logging features are available as static members of the Dts class. ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure. ' ' To open Code and Text Editor Help, press F1. ' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
Dim cDataFileName As String Dim cFileType As String Dim cFileFlgVar As String WriteVariable("SCFileFlg", False) WriteVariable("OOFileFlg", False) WriteVariable("INFileFlg", False) WriteVariable("IAFileFlg", False) WriteVariable("RCFileFlg", False) cDataFileName = ReadVariable("DataFileName").ToString cFileType = Left(Right(cDataFileName, 4), 2) cFileFlgVar = cFileType.ToUpper + "FileFlg" WriteVariable(cFileFlgVar, True) Dts.TaskResult = Dts.Results.Success End Sub Private Sub WriteVariable(ByVal varName As String, ByVal varValue As Object) Try Dim vars As Variables Dts.VariableDispenser.LockForWrite(varName) Dts.VariableDispenser.GetVariables(vars) Try vars(varName).Value = varValue Catch ex As Exception Throw ex Finally vars.Unlock() End Try Catch ex As Exception Throw ex End Try End Sub Private Function ReadVariable(ByVal varName As String) As Object Dim result As Object Try Dim vars As Variables Dts.VariableDispenser.LockForRead(varName) Dts.VariableDispenser.GetVariables(vars) Try result = vars(varName).Value Catch ex As Exception Throw ex Finally vars.Unlock() End Try Catch ex As Exception Throw ex End Try Return result End Function End Class
example for step 2: -------------------------------------------------------------------------------------------------------
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Public Sub Main()
Try
'Create the connection to the ftp server
Dim cm As ConnectionManager = Dts.Connections.Add("FTP")
It works remotely if I run it via command prompt. But when I add this to a TSQL job on my remote SQL instance, it runs without deleting anything. What I'm missing?
Hi, How can I generate a sequence No. using a simple SELECT statement.
like
declare @key set @key = 1
SELECT @key, e.name from Employee
Now I want to display name of the employee and Key value which should get incremented automatically for each employee.. Is there any way? Please help me..
i've been asked to write a sql sequence for a database i'm building but i haven't been using SQL very long and i have no idea how to write a sequence. Does anyone know anything about sql sequences?
Hi,I need little help with Ms SQL Server 2000. I would like to know how tocreate sequence or something like that. I want to have an automatic counterfor each row in one entity, so then I can do something like this:INSERT INTO table VALUES (use sequence(something), value, value, .... )Can you please help me?thxTomas
Brief overview...Running SQL Server 2003 Server Enterprise 64 bit - All Service Packs and patches current SQL Server 2005 Enterprise Edition 64 bit Build Microsoft SQL Server 2005 - 9.00.3054.00 (X64) Mar 23 2007 18:41:50 Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)
I cannot import any SSIS packages nor crete any new folders under stored packages. I hve googled the news groups and looked at BOL to no avail. HELP!!!!
I have a SQL 2005 stored procedure to generate an email when passed parameters such as receipient, subject etc One of the paramteres passed to it is @body which is the body text of the message. I want to be able to add a couple of blank lines and then some footer information. This is working right now except I can't find the right way to add newlines into the string within the store procedure, so my footer information just tags right on after the bodytext. I have tried but that literally adds the two characters and n Can anyone advise how to generate newlien sequences in T-SQL. Regards Clive
Hi, I've a question, if I've the LSN (Log Sequence Number) of a transaction, keep with the program "Log Explorer", can I know which is the IP of the user that have do the transaction (perhaps serching in a log file of the Win 2000 Server) ? 10x, Clara
I would like to know how it is possible to create a sequence with sql server 2000 With Postgres SQL i create the sequence essai : create sequence essai START 1; but i don't know what is the sql command.
SELECT @ddo = a.DDO_DSCR_SHORT FROM dbo.DIM_DDO a JOIN dbo.Temp_ABR_HDR b ON a.DDO_ID = b.DDO WHERE b.SESSIONID = @sessid
SELECT @ay = AY FROM dbo.Temp_ABR_HDR WHERE SESSIONID = @sessid
-- set the default seq_no SELECT @seq_no = 1 -- get the max abrid. if no record return the seq_no will be 1 SELECT @seq_no = convert(integer, max(right(abrid, 4))) FROM dbo.ABR_HDR WHERE left(abrid, 7) = @ay + @ddo
-- convert @seq_no to string prefix by 0 SELECT @abrid = @ay + @ddo + right('0000' + rtrim(convert(char(4), @seq_no)), 4)
SELECT @ddo = a.DDO_DSCR_SHORT FROM dbo.DIM_DDO a JOIN dbo.Temp_ABR_HDR b ON a.DDO_ID = b.DDO WHERE b.SESSIONID = @sessid
SELECT @ay = AY FROM dbo.Temp_ABR_HDR WHERE SESSIONID = @sessid
-- set the default seq_no --SELECT @seq_no = 1 -- get the max abrid. if no record return the seq_no will be 1 --SELECT @seq_no = convert(integer, max(right(abrid, 4))) --FROM dbo.ABR_HDR --WHERE left(abrid, 7) = @ay + @ddo
-- convert @seq_no to string prefix by 0 --SELECT @abrid = @ay + @ddo + right('0000' + rtrim(convert(char(4),@seq_no)), 4)
Hi, I am migrating a project from Oracle to SQLServer and must use the same DDL. The entities have compound primary keys. In Oracle I ensure the compound key is unique by using a sequence table to generate one of the values for the compound key. Does SQL Server have sequence tabels or does anybody know a way to get it do something similar? Thanks
is it possible to generate a number sequence in a query (without using loop). I want the output to look as ------- ID ------- 1 2 3 4 5 6 7 8 9 .... upto the last number I give in the query
I am not sure about the ANSI/ISO rules on this? We have a SEQUENCE and insert it into a table.
CREATE SEQUENCE Cheque_Seq AS INTEGER START WITH 1 INCREMENT BY 1; CREATE TABLE Cheque_Book (cheque_seq INTEGER*NOT NULL PRIMARY KEY, cheque_amt DECIMAL (15,2) DEFAULT 0.00 NOT NULL);
If I do an insertion with the SEQUENCE in a transaction and then ROLLBACK the transaction, what happens to the sequence value? My thought is that the value should reset to the state it was in before the transaction (basic definition of a ROLLBACK). But it does not in the products I have looked at.
I need to create a function that will return a sequence number. The reason I need this to be a function is that I will use the function to create a view. In Oracle I would do something like this:
create sequence seq;
create or replace function f return number as l_seq number; begin select seq.nextval into l_seq from dual; return l_seq; end; /
create or replace view v as select f from dual;
Since Sql Server does not have a sequence object I have created a sequence table with a identity column and a procedure that inserts a dummy variable and returns the identity id. This works ok but to get my sequence number I must declare a variable, execute the procedure and select the return value. I need the procedure to be a function so that I can use it to create my view. Since I cannot use DML in a function and I cannot call a procedure from a function I am stuck. Do I have to create an extended procedure ? Any help is appreciated
hey all, im having some problem to do this. i have this one table, that has sequence for other table. table : tblpicksequence (this sequence is dynamic eg : Non=1, cons=2, RET=3) picktypepicksequenceitemref RET1x1 Non2x1 Cons3x1 i need to select record from other table depend on tblpicksequence sequence table : tbldetail idRETNonCons 1001 2110 3100 4 001 so base on tblpicksequence, RET=1, NOn=2, Cons=3, i need to list the record from tbldetail :- i.list all RET=1 ii.if (i) not exists list all Non=1 iii.if (ii) not exists list all Cons=3 i expect :- idRETNonConspicksequencepicktype 21101RET 31001RET
Hello to every body I need to know about sequence of execution in a select command. I have a sql command that use a function.some thing like: select id, function(item) from tbl where conditions... I want to know that if my function on item execute before where section or vise versa. I try to explain it more. I want to know that sql engine fetch rows accordin to where clause and then execute my function or execute my funtion and then fetch the rows according to where clause.
If you have a document or some thing that explain about sql engine and sequence of execution please let me know.
I have a table in which there is 5 column ...one with numbers like...1,2,3,4,..20...and one column is with description....and other column with other details...
Now I want to disply my results in sequence followed by 1,2,3,4,5,17,18,15,16,10,11,20 with all other columns...so can anybody suggest me what to do..?
Hello all,Iīm currently using a SQL Serve 2K. Would like to do a selectwhich returns the row number - this should not be physically stored inthe database. So for example, I would like to do a query against theCUSTOMER table and receive:* rowID || name1 Evander2 Ron3 Scoth4 JaneI donīt want to store the ID, because if I change the order byclause, the sequence may modifiy, and, for another example, having thesame set of data, I would receive:* rowID || name1 Scoth2 Ron3 Jane4 Evander could someone help me ?best regards,Evandro
Hello,Since SQL Server has no sequence generator, I wrote my own. (I claimno ownership of it as it is closely modeled after earlier discussionson this topic.) I have included the sql statements below.While it works independently on its own, It seems to lock in multi-userenvironments or in nested-transactions. It s funny really: I have mymain transaction, but the sequence generator below forces anothertransaction, which I do not really care for. I cannot remove the extratransaction from the sequence generator because I would like to discardany values it retrieved, regardless of whether the main transactionsucceeded or failed.Any suggestions?--------------------------------------------------------------------------------create table my_sequence (name varchar(10), seq int identity (1, 1))godeclare @next intbegin transactionupdate my_sequence set seq = seq + 1 where name = 'abc';select @next = seq from my_sequence where name = 'abc';commit transaction---------------------------------------------------------
I have 2 tables which tab B depends on the record on tab A. In publisher, records are generated to tabA before some audit information record to tabB. In subscriber, there is replication error that the trigger in tab B couldn't find the corresponding record in tab A and cause the transactional replication error. And I found the comand_id within the same xact_segno of record in tab B is smaller than that of record in tab A. Does it mean the data in tab B replicate before tab A?
Also, how to know the replication sequence to the subscriber?