From ssharkins at gmail.com Thu Apr 2 11:17:56 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Thu, 2 Apr 2009 12:17:56 -0400 Subject: [dba-SQLServer] From a reader Message-ID: <6880B0BB53BA428F88A9712E5135262D@SusanOne> Without drawing a diagram, he loses me in para 2. Any help? Susan H. Could you be kind enough to clarify a BIG question I have about Transaction Log application? If I have a database in full recovery model (DB1) and I do a full backup I can then restore this backup on a different server (DB1_copy) and apply the transaction log backups from DB1 to DB1_copy. I should have no problem and my tests confirm this. But let's say I take a full backup of DB1 on Sunday. T-log backups of DB1 continue on an hourly basis. Monday morning, I restore DB1 on a different server as DB1_copy with NORECOVERY and start applying all T-log backups WITH NORECOVERY to DB1_copy that have been taken from DB1. Monday night, I take a full backup of DB1 but don't restore it to DB1_copy, instead I apply (or try to apply) the subsequent T-log backups of DB1 since Monday's full backup to DB1_copy. Based on my tests this doesn't work. Below is the SQL Server message. Does every full backup reset something internally ? Thanks David Agnew 305.905.6312 SQL Server message. Server: Msg 4326, Level 16, State 1, Line 1 The log in this backup set terminates at LSN 21000000025000001, which is too early to apply to the database. A more recent log backup that includes LSN 21000000040500001 can be restored. Server: Msg 3013, Level 16, State 1, Line 1 RESTORE LOG is terminating abnormally. From nancy.lytle at gmail.com Thu Apr 2 11:48:02 2009 From: nancy.lytle at gmail.com (Nancy Lytle) Date: Thu, 2 Apr 2009 11:48:02 -0500 Subject: [dba-SQLServer] From a reader In-Reply-To: <6880B0BB53BA428F88A9712E5135262D@SusanOne> References: <6880B0BB53BA428F88A9712E5135262D@SusanOne> Message-ID: What I think he is missing is that any data that was added/changed to DB1 from the last log backup before the Monday night full backup of DB1 to the beginning of the 1st log backup of DB1 after the full backup Monday night will be missing, and the somehow SQL Server knows this and that is why it won't allow that 'after full backup log' to be restored. Does that help any? Nancy Lytle N_Lytle at terpalum.umd.edu EMAILING FOR THE GREATER GOOD Join me > From: ssharkins at gmail.com > To: dba-SQLServer at databaseadvisors.com > Date: Thu, 2 Apr 2009 12:17:56 -0400 > Subject: [dba-SQLServer] From a reader > > Without drawing a diagram, he loses me in para 2. Any help? > > Susan H. > > > Could you be kind enough to clarify a BIG question I have about Transaction > Log application? If I have a database in full recovery model (DB1) and I do > a full backup I can then restore this backup on a different server > (DB1_copy) and apply the transaction log backups from DB1 to DB1_copy. I > should have no problem and my tests confirm this. > > > > But let's say I take a full backup of DB1 on Sunday. T-log backups of DB1 > continue on an hourly basis. Monday morning, I restore DB1 on a different > server as DB1_copy with NORECOVERY and start applying all T-log backups WITH > NORECOVERY to DB1_copy that have been taken from DB1. Monday night, I take a > full backup of DB1 but don't restore it to DB1_copy, instead I apply (or try > to apply) the subsequent T-log backups of DB1 since Monday's full backup to > DB1_copy. Based on my tests this doesn't work. Below is the SQL Server > message. Does every full backup reset something internally ? > > > > Thanks > > > > David Agnew > > 305.905.6312 > > > > SQL Server message. > > Server: Msg 4326, Level 16, State 1, Line 1 > > The log in this backup set terminates at LSN 21000000025000001, which is too > early to apply to the database. A more recent log backup that includes LSN > 21000000040500001 can be restored. > > Server: Msg 3013, Level 16, State 1, Line 1 > > RESTORE LOG is terminating abnormally. > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > From fhtapia at gmail.com Thu Apr 2 12:43:01 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Thu, 2 Apr 2009 10:43:01 -0700 Subject: [dba-SQLServer] From a reader In-Reply-To: References: <6880B0BB53BA428F88A9712E5135262D@SusanOne> Message-ID: All Sql Server Backups are Serialized, that means you need to restore in that specific order with a Full Backup always being the 1st backup you can restore. Thus if you reader restore the Sunday Full backup, and has a 2nd Full Backups on Monday, he needs to restore the 2nd Full backup with Monday's Logs in order to be up to date. If the user wishes to minimize the time of the restores (in case it's too big), then he would do well to schedule differential backups for the duration of the month while the diff backup file size is less than the full backup. This is subjective and it depends highly on the application. So he would be able to do 1) full restore from Sunday, followed by tlog restores 2) once the diff backup kicks off he would restore diff backups followed by tlog backups another option, as it sounds like what your user is doing is setting up a log shipping routine, for a standby server. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Thu, Apr 2, 2009 at 9:48 AM, Nancy Lytle wrote: > > What I think he is missing is that any data that was added/changed to DB1 > from the last log backup before the Monday night full backup of DB1 to the > beginning of the 1st log backup of DB1 after the full backup Monday night > will be missing, and the somehow SQL Server knows this and that is why it > won't allow that 'after full backup log' to be restored. > > > > Does that help any? > > Nancy Lytle > N_Lytle at terpalum.umd.edu > > > > > > > > > > > > EMAILING FOR THE GREATER GOOD > Join me > > > > > From: ssharkins at gmail.com > > To: dba-SQLServer at databaseadvisors.com > > Date: Thu, 2 Apr 2009 12:17:56 -0400 > > Subject: [dba-SQLServer] From a reader > > > > Without drawing a diagram, he loses me in para 2. Any help? > > > > Susan H. > > > > > > Could you be kind enough to clarify a BIG question I have about > Transaction > > Log application? If I have a database in full recovery model (DB1) and I > do > > a full backup I can then restore this backup on a different server > > (DB1_copy) and apply the transaction log backups from DB1 to DB1_copy. I > > should have no problem and my tests confirm this. > > > > > > > > But let's say I take a full backup of DB1 on Sunday. T-log backups of DB1 > > continue on an hourly basis. Monday morning, I restore DB1 on a different > > server as DB1_copy with NORECOVERY and start applying all T-log backups > WITH > > NORECOVERY to DB1_copy that have been taken from DB1. Monday night, I > take a > > full backup of DB1 but don't restore it to DB1_copy, instead I apply (or > try > > to apply) the subsequent T-log backups of DB1 since Monday's full backup > to > > DB1_copy. Based on my tests this doesn't work. Below is the SQL Server > > message. Does every full backup reset something internally ? > > > > > > > > Thanks > > > > > > > > David Agnew > > > > 305.905.6312 > > > > > > > > SQL Server message. > > > > Server: Msg 4326, Level 16, State 1, Line 1 > > > > The log in this backup set terminates at LSN 21000000025000001, which is > too > > early to apply to the database. A more recent log backup that includes > LSN > > 21000000040500001 can be restored. > > > > Server: Msg 3013, Level 16, State 1, Line 1 > > > > RESTORE LOG is terminating abnormally. > > > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From ssharkins at gmail.com Thu Apr 2 12:58:25 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Thu, 2 Apr 2009 13:58:25 -0400 Subject: [dba-SQLServer] From a reader References: <6880B0BB53BA428F88A9712E5135262D@SusanOne> Message-ID: <476D583365244AFE8CDAD38E754C64F9@SusanOne> Thanks Francisco and Nancy -- I don't support a SQL Server so these administrative issues are over my head. :) Susan H. > All Sql Server Backups are Serialized, that means you need to restore in > that specific order with a Full Backup always being the 1st backup you can > restore. Thus if you reader restore the Sunday Full backup, and has a 2nd > Full Backups on Monday, he needs to restore the 2nd Full backup with From ab-mi at post3.tele.dk Thu Apr 2 15:08:06 2009 From: ab-mi at post3.tele.dk (Asger Blond) Date: Thu, 2 Apr 2009 22:08:06 +0200 Subject: [dba-SQLServer] From a reader In-Reply-To: <476D583365244AFE8CDAD38E754C64F9@SusanOne> References: <6880B0BB53BA428F88A9712E5135262D@SusanOne> <476D583365244AFE8CDAD38E754C64F9@SusanOne> Message-ID: <5A56DADC153F487BB56A262E9A4FECF1@AB> Just tell him (as suggested by Francisco) to restore the most recent full backup with norecovery and then all subsequent log backups with norecovery except for the last log backup which should be restored with recovery. Asger -----Oprindelig meddelelse----- Fra: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] P? vegne af Susan Harkins Sendt: 2. april 2009 19:58 Til: Discussion concerning MS SQL Server Emne: Re: [dba-SQLServer] From a reader Thanks Francisco and Nancy -- I don't support a SQL Server so these administrative issues are over my head. :) Susan H. > All Sql Server Backups are Serialized, that means you need to restore in > that specific order with a Full Backup always being the 1st backup you can > restore. Thus if you reader restore the Sunday Full backup, and has a 2nd > Full Backups on Monday, he needs to restore the 2nd Full backup with _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From ssharkins at gmail.com Thu Apr 2 15:54:57 2009 From: ssharkins at gmail.com (Susan Harkins) Date: Thu, 2 Apr 2009 16:54:57 -0400 Subject: [dba-SQLServer] From a reader References: <6880B0BB53BA428F88A9712E5135262D@SusanOne><476D583365244AFE8CDAD38E754C64F9@SusanOne> <5A56DADC153F487BB56A262E9A4FECF1@AB> Message-ID: <3003F861A53B4A50B63BFAE88E3858FB@SusanOne> I sent the reader a compilation of all the responses and he says it's very helpful -- thanks to everyone for your help! Susan H. Just tell him (as suggested by Francisco) to restore the most recent full backup with norecovery and then all subsequent log backups with norecovery except for the last log backup which should be restored with recovery. From fuller.artful at gmail.com Tue Apr 14 21:05:36 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Tue, 14 Apr 2009 22:05:36 -0400 Subject: [dba-SQLServer] SQL Rootkits Message-ID: <29f585dd0904141905g4c3f6072wc93e63907853b363@mail.gmail.com> I was speaking with a security specialist at a large Canadian bank this evening and he mentioned that they have seen several SQL Server rootkits that can grab all the instance, logins, passwords, etc., and even create hidden users invisible even to administrators. Has anyone heard of these? Been bitten? Arthur From fhtapia at gmail.com Wed Apr 15 00:01:02 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Tue, 14 Apr 2009 22:01:02 -0700 Subject: [dba-SQLServer] SQL Rootkits In-Reply-To: <29f585dd0904141905g4c3f6072wc93e63907853b363@mail.gmail.com> References: <29f585dd0904141905g4c3f6072wc93e63907853b363@mail.gmail.com> Message-ID: I've heard of it in the cases of sql injections, our old sql server was forward facing and attached to iis, i know, but it was, it had been hacked several times and rootkit'ed well, even MS suggested we just scrap the drives and start all over, the data was recoverable and I had to do a lot of scrubbing of fields that were no good. but having been lucky enough to collect all user information from before the attacks I was able to rebuild my user id's and structures. I will note that sp_revlogin did reveal all new system admin id's that I was not able to delete w/ SA, but they were all visible. http://sansforensics.wordpress.com/2009/03/27/sql-rootkits/ -Francisco http://sqlthis.blogspot.com | Tsql and More... On Tue, Apr 14, 2009 at 7:05 PM, Arthur Fuller wrote: > I was speaking with a security specialist at a large Canadian bank this > evening and he mentioned that they have seen several SQL Server rootkits > that can grab all the instance, logins, passwords, etc., and even create > hidden users invisible even to administrators. > > Has anyone heard of these? Been bitten? > > Arthur > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From paul.hartland at googlemail.com Wed Apr 15 03:32:24 2009 From: paul.hartland at googlemail.com (Paul Hartland) Date: Wed, 15 Apr 2009 09:32:24 +0100 Subject: [dba-SQLServer] Passing variable to xp cmdshell Message-ID: <38c884770904150132q33ed14bi2aa774eaa502ac75@mail.gmail.com> To all, I am having a problem using xp cmdshell in SQL Server 2005, I won't go into too much detail but basically I am just trying to put a folder list into a temporary table. if I use exec master..xp cmdshell 'dir "myserver\myinitialfolder" /b' it works fine, however I need to generate the folder on the fly, but if I declare a variable say @folder varchar(4000) and then have exec master..xp cmdshell @folder I get Msg 214, Level 16, State 201, Procedure xp cmdshell, Line 1 Procedure expects parameter 'command_string' of type 'varchar'. Anyone any ideas whats happening, or what I am doing wrong ? Thanks is advance for any help on this. -- Paul Hartland paul.hartland at googlemail.com From fhtapia at gmail.com Wed Apr 15 09:59:37 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Wed, 15 Apr 2009 07:59:37 -0700 Subject: [dba-SQLServer] Passing variable to xp cmdshell In-Reply-To: <38c884770904150132q33ed14bi2aa774eaa502ac75@mail.gmail.com> References: <38c884770904150132q33ed14bi2aa774eaa502ac75@mail.gmail.com> Message-ID: I've always pushed my results to a table and not a variable... let me dig up what i've done before SET @fPath = 'dir "myserver\myinitialfolder" / b' SET @sCommand = @fPath INSERT INTO #tmptable (Field2) EXEC master..xp_cmdshell @sCommand -Francisco http://sqlthis.blogspot.com | Tsql and More... On Wed, Apr 15, 2009 at 1:32 AM, Paul Hartland wrote: > To all, > > I am having a problem using xp cmdshell in SQL Server 2005, I won't go into > too much detail but basically I am just trying to put a folder list into a > temporary table. > > if I use exec master..xp cmdshell 'dir "myserver\myinitialfolder" /b' it > works fine, however I need to generate the folder on the fly, but if I > declare a variable say @folder varchar(4000) and then have exec master..xp > cmdshell @folder I get > > Msg 214, Level 16, State 201, Procedure xp cmdshell, Line 1 > Procedure expects parameter 'command_string' of type 'varchar'. > > Anyone any ideas whats happening, or what I am doing wrong ? > > Thanks is advance for any help on this. > > -- > Paul Hartland > paul.hartland at googlemail.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From dbdoug at gmail.com Wed Apr 15 10:22:48 2009 From: dbdoug at gmail.com (Doug Steele) Date: Wed, 15 Apr 2009 08:22:48 -0700 Subject: [dba-SQLServer] Passing variable to xp cmdshell In-Reply-To: <38c884770904150132q33ed14bi2aa774eaa502ac75@mail.gmail.com> References: <38c884770904150132q33ed14bi2aa774eaa502ac75@mail.gmail.com> Message-ID: <4dd71a0c0904150822t79ddc0auad8e89ca34eae185@mail.gmail.com> The following worked for me: 1. (from the Help system) DECLARE @cmd sysname, @var sysname SET @var = 'Hello world' SET @cmd = 'echo ' + @var + ' > var_out.txt' EXEC master..xp_cmdshell @cmd 2. CREATE PROCEDURE zz (@cmdin varchar(255)) AS EXEC master..xp_cmdshell @cmdin followed by exec zz 'dir "E:\A_Projects"' Doug Steele On Wed, Apr 15, 2009 at 1:32 AM, Paul Hartland wrote: > To all, > > I am having a problem using xp cmdshell in SQL Server 2005, I won't go into > too much detail but basically I am just trying to put a folder list into a > temporary table. > > if I use exec master..xp cmdshell 'dir "myserver\myinitialfolder" /b' it > works fine, however I need to generate the folder on the fly, but if I > declare a variable say @folder varchar(4000) and then have exec master..xp > cmdshell @folder I get > > Msg 214, Level 16, State 201, Procedure xp cmdshell, Line 1 > Procedure expects parameter 'command_string' of type 'varchar'. > > Anyone any ideas whats happening, or what I am doing wrong ? > > Thanks is advance for any help on this. > > -- > Paul Hartland > paul.hartland at googlemail.com > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jnatola at hotmail.com Thu Apr 16 12:30:29 2009 From: jnatola at hotmail.com (jean-paul natola) Date: Thu, 16 Apr 2009 13:30:29 -0400 Subject: [dba-SQLServer] Stored proc help for a newb Message-ID: Hi all, I'm having a problem that I hope can help me out- there is a stored procedure in a database (took me a while just to figure where to locate stored procs) now that I have found it - i'm trying to import records from an excel file using the stored proc (if thats even possible) i'm totally new as you can see - can someone help me shed some light on this GREATLY appreciated J Windows Live?: Life without walls. Check it out. _________________________________________________________________ Rediscover Hotmail?: Get e-mail storage that grows with you. http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009 From dbdoug at gmail.com Thu Apr 16 12:51:06 2009 From: dbdoug at gmail.com (Doug Steele) Date: Thu, 16 Apr 2009 10:51:06 -0700 Subject: [dba-SQLServer] Stored proc help for a newb In-Reply-To: References: Message-ID: <4dd71a0c0904161051i18a6ab68o92acef6adcdd1536@mail.gmail.com> Google is your friend. http://support.microsoft.com/kb/321686 The section under 'Use Distributed Queries' shows you how to do it in one line of SQL. Doug Steele > Hi all, > > I'm having a problem that I hope can help me out- there is a stored > procedure in a database (took me a while just to figure where to locate > stored procs) now that I have found it - i'm trying to import records from > an excel file using the stored proc (if thats even possible) i'm totally new > as you can see - > > can someone help me shed some light on this > > GREATLY appreciated > > From jnatola at hotmail.com Thu Apr 16 14:43:59 2009 From: jnatola at hotmail.com (jean-paul natola) Date: Thu, 16 Apr 2009 15:43:59 -0400 Subject: [dba-SQLServer] Stored proc help for a newb In-Reply-To: <4dd71a0c0904161051i18a6ab68o92acef6adcdd1536@mail.gmail.com> References: <4dd71a0c0904161051i18a6ab68o92acef6adcdd1536@mail.gmail.com> Message-ID: Thanks for the reply, and please excuse me if I sound ignorant or dont make any sense, but I see no mention of using the SPROC , that only shows me how to get data from an excle file into one table. The problem I have is that in teh DB there are 3 tables that are used in creating the record, so this is where I'm getting lost TIA > Date: Thu, 16 Apr 2009 10:51:06 -0700 > From: dbdoug at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] Stored proc help for a newb > > Google is your friend. > > http://support.microsoft.com/kb/321686 > > The section under 'Use Distributed Queries' shows you how to do it in one > line of SQL. > > Doug Steele > > > > Hi all, > > > > I'm having a problem that I hope can help me out- there is a stored > > procedure in a database (took me a while just to figure where to locate > > stored procs) now that I have found it - i'm trying to import records from > > an excel file using the stored proc (if thats even possible) i'm totally new > > as you can see - > > > > can someone help me shed some light on this > > > > GREATLY appreciated > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1b_explore_042009 From dbdoug at gmail.com Thu Apr 16 15:15:05 2009 From: dbdoug at gmail.com (Doug Steele) Date: Thu, 16 Apr 2009 13:15:05 -0700 Subject: [dba-SQLServer] Stored proc help for a newb In-Reply-To: References: <4dd71a0c0904161051i18a6ab68o92acef6adcdd1536@mail.gmail.com> Message-ID: <4dd71a0c0904161315o6f334f58gd18815fafa3660bc@mail.gmail.com> I'm not clear on what your problem is exactly. Are you saying that you have SQL code that imports from Excel, and that you want to turn it into an SPROC, or do you have an SPROC which you can't figure out how to use? Can you give a bit more detail? Doug Steele On Thu, Apr 16, 2009 at 12:43 PM, jean-paul natola wrote: > > Thanks for the reply, > > and please excuse me if I sound ignorant or dont make any sense, but I see > no mention of using the SPROC , that only shows me how to get data from an > excle file into one table. > > > > The problem I have is that in teh DB there are 3 tables that are used in > creating the record, so this is where I'm getting lost > > > > TIA > > > Date: Thu, 16 Apr 2009 10:51:06 -0700 > > From: dbdoug at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] Stored proc help for a newb > > > > Google is your friend. > > > > http://support.microsoft.com/kb/321686 > > > > The section under 'Use Distributed Queries' shows you how to do it in one > > line of SQL. > > > > Doug Steele > > > > > > > Hi all, > > > > > > I'm having a problem that I hope can help me out- there is a stored > > > procedure in a database (took me a while just to figure where to locate > > > stored procs) now that I have found it - i'm trying to import records > from > > > an excel file using the stored proc (if thats even possible) i'm > totally new > > > as you can see - > > > > > > can someone help me shed some light on this > > > > > > GREATLY appreciated > > > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > _________________________________________________________________ > Windows Live?: Life without walls. > http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1b_explore_042009 > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From jnatola at hotmail.com Thu Apr 16 16:05:07 2009 From: jnatola at hotmail.com (jean-paul natola) Date: Thu, 16 Apr 2009 17:05:07 -0400 Subject: [dba-SQLServer] Stored proc help for a newb In-Reply-To: <4dd71a0c0904161315o6f334f58gd18815fafa3660bc@mail.gmail.com> References: <4dd71a0c0904161051i18a6ab68o92acef6adcdd1536@mail.gmail.com> <4dd71a0c0904161315o6f334f58gd18815fafa3660bc@mail.gmail.com> Message-ID: ok, in our app we add records that contain various pieces of data there are three tables that make up the record- aag00400 aag00401 aag10001 there is sproc (comes builtin to the db) called dbo.taAATrxDimCodeMaint ftp://ftp.fcimail.org/IT/sproc.rtf you view it here now somehow (i think) i'm suppose to be utilize the sproc to do a mass import of records, does this make sense? Jean-Paul Natola > Date: Thu, 16 Apr 2009 13:15:05 -0700 > From: dbdoug at gmail.com > To: dba-sqlserver at databaseadvisors.com > Subject: Re: [dba-SQLServer] Stored proc help for a newb > > I'm not clear on what your problem is exactly. > > Are you saying that you have SQL code that imports from Excel, and that you > want to turn it into an SPROC, or do you have an SPROC which you can't > figure out how to use? Can you give a bit more detail? > > Doug Steele > > On Thu, Apr 16, 2009 at 12:43 PM, jean-paul natola wrote: > > > > > Thanks for the reply, > > > > and please excuse me if I sound ignorant or dont make any sense, but I see > > no mention of using the SPROC , that only shows me how to get data from an > > excle file into one table. > > > > > > > > The problem I have is that in teh DB there are 3 tables that are used in > > creating the record, so this is where I'm getting lost > > > > > > > > TIA > > > > > Date: Thu, 16 Apr 2009 10:51:06 -0700 > > > From: dbdoug at gmail.com > > > To: dba-sqlserver at databaseadvisors.com > > > Subject: Re: [dba-SQLServer] Stored proc help for a newb > > > > > > Google is your friend. > > > > > > http://support.microsoft.com/kb/321686 > > > > > > The section under 'Use Distributed Queries' shows you how to do it in one > > > line of SQL. > > > > > > Doug Steele > > > > > > > > > > Hi all, > > > > > > > > I'm having a problem that I hope can help me out- there is a stored > > > > procedure in a database (took me a while just to figure where to locate > > > > stored procs) now that I have found it - i'm trying to import records > > from > > > > an excel file using the stored proc (if thats even possible) i'm > > totally new > > > > as you can see - > > > > > > > > can someone help me shed some light on this > > > > > > > > GREATLY appreciated > > > > > > > > > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > > _________________________________________________________________ > > Windows Live?: Life without walls. > > http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1b_explore_042009 > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > _________________________________________________________________ Windows Live?: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009 From dbdoug at gmail.com Thu Apr 16 17:38:21 2009 From: dbdoug at gmail.com (Doug Steele) Date: Thu, 16 Apr 2009 15:38:21 -0700 Subject: [dba-SQLServer] Stored proc help for a newb In-Reply-To: References: <4dd71a0c0904161051i18a6ab68o92acef6adcdd1536@mail.gmail.com> <4dd71a0c0904161315o6f334f58gd18815fafa3660bc@mail.gmail.com> Message-ID: <4dd71a0c0904161538q6e0ee56at4a9313031903f11b@mail.gmail.com> What you sent was a screenshot of the 30 plus parameters that your SPROC needs; this is pretty much meaningless to anyone who doesn't have access to your database or its documentation. I would say that you and I are totally out of our depth at this point. You need to find someone who knows this database. Doug Steele On Thu, Apr 16, 2009 at 2:05 PM, jean-paul natola wrote: > > ok, in our app we add records that contain various pieces of data > > > > there are three tables that make up the record- > > > > aag00400 > > aag00401 > > aag10001 > > > > there is sproc (comes builtin to the db) called dbo.taAATrxDimCodeMaint > > > > ftp://ftp.fcimail.org/IT/sproc.rtf > > > > you view it here > > > > now somehow (i think) i'm suppose to be utilize the sproc to do a mass > import of records, > > > > does this make sense? > > > > From fhtapia at gmail.com Thu Apr 16 22:58:02 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Thu, 16 Apr 2009 20:58:02 -0700 Subject: [dba-SQLServer] Stored proc help for a newb In-Reply-To: References: <4dd71a0c0904161051i18a6ab68o92acef6adcdd1536@mail.gmail.com> <4dd71a0c0904161315o6f334f58gd18815fafa3660bc@mail.gmail.com> Message-ID: i don't know why, but I can't see anything on the file you posted. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Thu, Apr 16, 2009 at 2:05 PM, jean-paul natola wrote: > > ok, in our app we add records that contain various pieces of data > > > > there are three tables that make up the record- > > > > aag00400 > > aag00401 > > aag10001 > > > > there is sproc (comes builtin to the db) called dbo.taAATrxDimCodeMaint > > > > ftp://ftp.fcimail.org/IT/sproc.rtf > > > > you view it here > > > > now somehow (i think) i'm suppose to be utilize the sproc to do a mass > import of records, > > > > does this make sense? > > > > > > > > > > > > > > > > > > > > > > > > Jean-Paul Natola > > > > > > > Date: Thu, 16 Apr 2009 13:15:05 -0700 > > From: dbdoug at gmail.com > > To: dba-sqlserver at databaseadvisors.com > > Subject: Re: [dba-SQLServer] Stored proc help for a newb > > > > I'm not clear on what your problem is exactly. > > > > Are you saying that you have SQL code that imports from Excel, and that > you > > want to turn it into an SPROC, or do you have an SPROC which you can't > > figure out how to use? Can you give a bit more detail? > > > > Doug Steele > > > > On Thu, Apr 16, 2009 at 12:43 PM, jean-paul natola >wrote: > > > > > > > > Thanks for the reply, > > > > > > and please excuse me if I sound ignorant or dont make any sense, but I > see > > > no mention of using the SPROC , that only shows me how to get data from > an > > > excle file into one table. > > > > > > > > > > > > The problem I have is that in teh DB there are 3 tables that are used > in > > > creating the record, so this is where I'm getting lost > > > > > > > > > > > > TIA > > > > > > > Date: Thu, 16 Apr 2009 10:51:06 -0700 > > > > From: dbdoug at gmail.com > > > > To: dba-sqlserver at databaseadvisors.com > > > > Subject: Re: [dba-SQLServer] Stored proc help for a newb > > > > > > > > Google is your friend. > > > > > > > > http://support.microsoft.com/kb/321686 > > > > > > > > The section under 'Use Distributed Queries' shows you how to do it in > one > > > > line of SQL. > > > > > > > > Doug Steele > > > > > > > > > > > > > Hi all, > > > > > > > > > > I'm having a problem that I hope can help me out- there is a stored > > > > > procedure in a database (took me a while just to figure where to > locate > > > > > stored procs) now that I have found it - i'm trying to import > records > > > from > > > > > an excel file using the stored proc (if thats even possible) i'm > > > totally new > > > > > as you can see - > > > > > > > > > > can someone help me shed some light on this > > > > > > > > > > GREATLY appreciated > > > > > > > > > > > > > > _______________________________________________ > > > > dba-SQLServer mailing list > > > > dba-SQLServer at databaseadvisors.com > > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > > http://www.databaseadvisors.com > > > > > > > > > > _________________________________________________________________ > > > Windows Live?: Life without walls. > > > > http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1b_explore_042009 > > > _______________________________________________ > > > dba-SQLServer mailing list > > > dba-SQLServer at databaseadvisors.com > > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > > http://www.databaseadvisors.com > > > > > > > > _______________________________________________ > > dba-SQLServer mailing list > > dba-SQLServer at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > > http://www.databaseadvisors.com > > > > _________________________________________________________________ > Windows Live?: Keep your life in sync. > http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009 > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Thu Apr 23 05:56:47 2009 From: fuller.artful at gmail.com (Arthur Fuller) Date: Thu, 23 Apr 2009 06:56:47 -0400 Subject: [dba-SQLServer] Come visit Message-ID: <29f585dd0904230356i7db835b0vaa7c80bf10bff74e@mail.gmail.com> Please come visit our site and read/enjoy. It's the Toronto SQL Server User Group. www.tsql.ca. Membership is free. Thanks, Arthur From sdunlap at brownshoe.com Thu Apr 23 08:20:31 2009 From: sdunlap at brownshoe.com (sdunlap at brownshoe.com) Date: Thu, 23 Apr 2009 08:20:31 -0500 Subject: [dba-SQLServer] Automating the creation of views Message-ID: Hi, I'm new to SQL Server and I've been tasked with creating a lot of views (over 100). I'm using SQL Server 2005. The process of creating these views will be repetitive, and I'm wondering if there is some way to automate the creation of the views. More details on the task at hand...I have a whole bunch of views in a database, View1, View2, View3 ....... ViewN. For the purposes of this example, this database would be called 'OriginalDatabase'. In another database, the views I need to create will be: SELECT * FROM OriginalDatabase.dbo.ViewX In the SQL above, ViewX represents the view 1, 2, 3 or N. I would want to be able to generate the list of Views (1, 2, 3 ... N) by programmatically reading the available views in the OriginalDatabase views folder and selecting only the views I need based on a naming convention - specifically, the first three characters of the view name = 'nnn'. I have a book on SQL Server 2005, but I haven't been successful using the index to find help on this, mainly because I'm not sure what topic this would fall under. Does anyone know if it is possible to automate the creation of the views? Any insight is appreciated. Thanks, Stu From Betsy.Powlen at stanleyassociates.com Thu Apr 23 08:33:03 2009 From: Betsy.Powlen at stanleyassociates.com (Powlen, Betsy) Date: Thu, 23 Apr 2009 09:33:03 -0400 Subject: [dba-SQLServer] Automating the creation of views Message-ID: <2A419A21A2A23243A9E7851EEDBDC122B0896D@OP-S-EX-2.stanleyassociates.com> Hi Stu, It sounds to me like you want to copy certain views to your new database. Is this correct? If so, you can use Data Transformation Service (DTS) from Enterprise Manager. With this, you can export whatever views you need and the dependant objects all in one action. Betsy -----Original Message----- From: dba-sqlserver-bounces at databaseadvisors.com [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of sdunlap at brownshoe.com Sent: Thursday, April 23, 2009 9:21 AM To: dba-sqlserver at databaseadvisors.com Subject: [dba-SQLServer] Automating the creation of views Hi, I'm new to SQL Server and I've been tasked with creating a lot of views (over 100). I'm using SQL Server 2005. The process of creating these views will be repetitive, and I'm wondering if there is some way to automate the creation of the views. More details on the task at hand...I have a whole bunch of views in a database, View1, View2, View3 ....... ViewN. For the purposes of this example, this database would be called 'OriginalDatabase'. In another database, the views I need to create will be: SELECT * FROM OriginalDatabase.dbo.ViewX In the SQL above, ViewX represents the view 1, 2, 3 or N. I would want to be able to generate the list of Views (1, 2, 3 ... N) by programmatically reading the available views in the OriginalDatabase views folder and selecting only the views I need based on a naming convention - specifically, the first three characters of the view name = 'nnn'. I have a book on SQL Server 2005, but I haven't been successful using the index to find help on this, mainly because I'm not sure what topic this would fall under. Does anyone know if it is possible to automate the creation of the views? Any insight is appreciated. Thanks, Stu _______________________________________________ dba-SQLServer mailing list dba-SQLServer at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-sqlserver http://www.databaseadvisors.com From fhtapia at gmail.com Thu Apr 23 09:11:11 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Thu, 23 Apr 2009 07:11:11 -0700 Subject: [dba-SQLServer] Automating the creation of views In-Reply-To: <2A419A21A2A23243A9E7851EEDBDC122B0896D@OP-S-EX-2.stanleyassociates.com> References: <2A419A21A2A23243A9E7851EEDBDC122B0896D@OP-S-EX-2.stanleyassociates.com> Message-ID: he is in sql server 2005 from what I read, thus DTS won't really help connecting, plus technically you can't create any new dts jobs on sql server 2005 (yes you can always duplicate an existing dts package to create a new one, but I digress). In this instance there is a ssis wizard that would help you copy the views you want to your new database. -Francisco http://sqlthis.blogspot.com | Tsql and More... On Thu, Apr 23, 2009 at 6:33 AM, Powlen, Betsy < Betsy.Powlen at stanleyassociates.com> wrote: > Hi Stu, > It sounds to me like you want to copy certain views to your new > database. Is this correct? If so, you can use Data Transformation > Service (DTS) from Enterprise Manager. With this, you can export > whatever views you need and the dependant objects all in one action. > Betsy > > > -----Original Message----- > From: dba-sqlserver-bounces at databaseadvisors.com > [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of > sdunlap at brownshoe.com > Sent: Thursday, April 23, 2009 9:21 AM > To: dba-sqlserver at databaseadvisors.com > Subject: [dba-SQLServer] Automating the creation of views > > Hi, > > I'm new to SQL Server and I've been tasked with creating a lot of views > (over 100). I'm using SQL Server 2005. > > The process of creating these views will be repetitive, and I'm > wondering if there is some way to automate the creation of the views. > > More details on the task at hand...I have a whole bunch of views in a > database, View1, View2, View3 ....... ViewN. For the purposes of this > example, this database would be called 'OriginalDatabase'. > > In another database, the views I need to create will be: SELECT * > FROM > OriginalDatabase.dbo.ViewX > > In the SQL above, ViewX represents the view 1, 2, 3 or N. I would want > to be able to generate the list of Views (1, 2, 3 ... N) by > programmatically reading the available views in the OriginalDatabase > views folder and selecting only the views I need based on a naming > convention - specifically, the first three characters of the view name = > 'nnn'. > > I have a book on SQL Server 2005, but I haven't been successful using > the index to find help on this, mainly because I'm not sure what topic > this would fall under. > > Does anyone know if it is possible to automate the creation of the > views? > > Any insight is appreciated. > > Thanks, > Stu > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > > _______________________________________________ > dba-SQLServer mailing list > dba-SQLServer at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-sqlserver > http://www.databaseadvisors.com > > From fhtapia at gmail.com Thu Apr 23 09:12:34 2009 From: fhtapia at gmail.com (Francisco Tapia) Date: Thu, 23 Apr 2009 07:12:34 -0700 Subject: [dba-SQLServer] Automating the creation of views In-Reply-To: References: <2A419A21A2A23243A9E7851EEDBDC122B0896D@OP-S-EX-2.stanleyassociates.com> Message-ID: For info on the wizard just follow this link... http://sqlthis.blogspot.com/2009/03/ssis-sos.html -Francisco http://sqlthis.blogspot.com | Tsql and More... On Thu, Apr 23, 2009 at 7:11 AM, Francisco Tapia wrote: > he is in sql server 2005 from what I read, thus DTS won't really help > connecting, plus technically you can't create any new dts jobs on sql server > 2005 (yes you can always duplicate an existing dts package to create a new > one, but I digress). In this instance there is a ssis wizard that would > help you copy the views you want to your new database. > > -Francisco > http://sqlthis.blogspot.com | Tsql and More... > > > > On Thu, Apr 23, 2009 at 6:33 AM, Powlen, Betsy < > Betsy.Powlen at stanleyassociates.com> wrote: > >> Hi Stu, >> It sounds to me like you want to copy certain views to your new >> database. Is this correct? If so, you can use Data Transformation >> Service (DTS) from Enterprise Manager. With this, you can export >> whatever views you need and the dependant objects all in one action. >> Betsy >> >> >> -----Original Message----- >> From: dba-sqlserver-bounces at databaseadvisors.com >> [mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of >> sdunlap at brownshoe.com >> Sent: Thursday, April 23, 2009 9:21 AM >> To: dba-sqlserver at databaseadvisors.com >> Subject: [dba-SQLServer] Automating the creation of views >> >> Hi, >> >> I'm new to SQL Server and I've been tasked with creating a lot of views >> (over 100). I'm using SQL Server 2005. >> >> The process of creating these views will be repetitive, and I'm >> wondering if there is some way to automate the creation of the views. >> >> More details on the task at hand...I have a whole bunch of views in a >> database, View1, View2, View3 ....... ViewN. For the purposes of this >> example, this database would be called 'OriginalDatabase'. >> >> In another database, the views I need to create will be: SELECT * >> FROM >> OriginalDatabase.dbo.ViewX >> >> In the SQL above, ViewX represents the view 1, 2, 3 or N. I would want >> to be able to generate the list of Views (1, 2, 3 ... N) by >> programmatically reading the available views in the OriginalDatabase >> views folder and selecting only the views I need based on a naming >> convention - specifically, the first three characters of the view name = >> 'nnn'. >> >> I have a book on SQL Server 2005, but I haven't been successful using >> the index to find help on this, mainly because I'm not sure what topic >> this would fall under. >> >> Does anyone know if it is possible to automate the creation of the >> views? >> >> Any insight is appreciated. >> >> Thanks, >> Stu >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> >> _______________________________________________ >> dba-SQLServer mailing list >> dba-SQLServer at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >> http://www.databaseadvisors.com >> >> > From sdunlap at brownshoe.com Fri Apr 24 08:14:53 2009 From: sdunlap at brownshoe.com (sdunlap at brownshoe.com) Date: Fri, 24 Apr 2009 08:14:53 -0500 Subject: [dba-SQLServer] Automating the creation of views In-Reply-To: Message-ID: Francisco / Betsy, Thank you both for your replies. Francisco, I read the article you provided, but I'm still stuck. I'm able to successfully transport the results of the View from the source database to a table in the target database using the SSIS wizard. However, what I want to do is take a view from the source database, such as: "SELECT * FROM dbo.MySourceTable WHERE MyField = 'xxx'" and create a new view in the target database like this: "SELECT * FROM SourceDatabase.dbo.MySourceTable WHERE MyField = 'xxx'" ... or alternatively, I suppose it could be: "SELECT * FROM SourceDatabase.dbo.MyView" Does anyone know of a way to have the view copied into the target database as a view? Thanks, Stu ===================================================== dba-sqlserver-request at databaseadvisors.com Sent by: dba-sqlserver-bounces at databaseadvisors.com 04/23/2009 12:00 PM Please respond to dba-sqlserver at databaseadvisors.com To dba-sqlserver at databaseadvisors.com cc Subject dba-SQLServer Digest, Vol 74, Issue 5 Today's Topics: 1. Come visit (Arthur Fuller) 2. Automating the creation of views (sdunlap at brownshoe.com) 3. Re: Automating the creation of views (Powlen, Betsy) 4. Re: Automating the creation of views (Francisco Tapia) 5. Re: Automating the creation of views (Francisco Tapia) ------------------------------ Message: 2 Date: Thu, 23 Apr 2009 08:20:31 -0500 From: sdunlap at brownshoe.com Subject: [dba-SQLServer] Automating the creation of views To: dba-sqlserver at databaseadvisors.com Message-ID: Content-Type: text/plain; charset="US-ASCII" Hi, I'm new to SQL Server and I've been tasked with creating a lot of views (over 100). I'm using SQL Server 2005. The process of creating these views will be repetitive, and I'm wondering if there is some way to automate the creation of the views. More details on the task at hand...I have a whole bunch of views in a database, View1, View2, View3 ....... ViewN. For the purposes of this example, this database would be called 'OriginalDatabase'. In another database, the views I need to create will be: SELECT * FROM OriginalDatabase.dbo.ViewX In the SQL above, ViewX represents the view 1, 2, 3 or N. I would want to be able to generate the list of Views (1, 2, 3 ... N) by programmatically reading the available views in the OriginalDatabase views folder and selecting only the views I need based on a naming convention - specifically, the first three characters of the view name = 'nnn'. I have a book on SQL Server 2005, but I haven't been successful using the index to find help on this, mainly because I'm not sure what topic this would fall under. Does anyone know if it is possible to automate the creation of the views? Any insight is appreciated. Thanks, Stu ------------------------------ Message: 3 Date: Thu, 23 Apr 2009 09:33:03 -0400 From: "Powlen, Betsy" Subject: Re: [dba-SQLServer] Automating the creation of views To: "Discussion concerning MS SQL Server" Message-ID: <2A419A21A2A23243A9E7851EEDBDC122B0896D at OP-S-EX-2.stanleyassociates.com> Content-Type: text/plain; charset="us-ascii" Hi Stu, It sounds to me like you want to copy certain views to your new database. Is this correct? If so, you can use Data Transformation Service (DTS) from Enterprise Manager. With this, you can export whatever views you need and the dependant objects all in one action. Betsy ------------------------------ Message: 4 Date: Thu, 23 Apr 2009 07:11:11 -0700 From: Francisco Tapia Subject: Re: [dba-SQLServer] Automating the creation of views To: Discussion concerning MS SQL Server Message-ID: Content-Type: text/plain; charset=ISO-8859-1 he is in sql server 2005 from what I read, thus DTS won't really help connecting, plus technically you can't create any new dts jobs on sql server 2005 (yes you can always duplicate an existing dts package to create a new one, but I digress). In this instance there is a ssis wizard that would help you copy the views you want to your new database. -Francisco http://sqlthis.blogspot.com | Tsql and More... ------------------------------ Message: 5 Date: Thu, 23 Apr 2009 07:12:34 -0700 From: Francisco Tapia Subject: Re: [dba-SQLServer] Automating the creation of views To: Discussion concerning MS SQL Server Message-ID: Content-Type: text/plain; charset=ISO-8859-1 For info on the wizard just follow this link... http://sqlthis.blogspot.com/2009/03/ssis-sos.html -Francisco http://sqlthis.blogspot.com | Tsql and More... From robert at webedb.com Fri Apr 24 14:00:25 2009 From: robert at webedb.com (Robert L. Stewart) Date: Fri, 24 Apr 2009 14:00:25 -0500 Subject: [dba-SQLServer] Automating the creation of views In-Reply-To: References: Message-ID: <200904241901.n3OJ10eK012020@databaseadvisors.com> Stu, When you right click on a view, you can edit it. When you edit it, you get the SQL script. Change the alter to create. Add the sourcedatabase. where you need to. Right click on the view tab. change the connection to the database you want to save it in. Execute the SQL. There is no way of automating it beyond that. At 12:00 PM 4/24/2009, you wrote: >Date: Fri, 24 Apr 2009 08:14:53 -0500 >From: sdunlap at brownshoe.com >Subject: Re: [dba-SQLServer] Automating the creation of views >To: dba-sqlserver at databaseadvisors.com >Message-ID: > > > >Content-Type: text/plain; charset="US-ASCII" > >Francisco / Betsy, > >Thank you both for your replies. Francisco, I read the article you >provided, but I'm still stuck. I'm able to successfully transport the >results of the View from the source database to a table in the target >database using the SSIS wizard. >However, what I want to do is take a view from the source database, such >as: "SELECT * FROM dbo.MySourceTable WHERE MyField = 'xxx'" > >and create a new view in the target database like this: "SELECT * FROM >SourceDatabase.dbo.MySourceTable WHERE MyField = 'xxx'" > >... or alternatively, I suppose it could be: "SELECT * FROM >SourceDatabase.dbo.MyView" > >Does anyone know of a way to have the view copied into the target database >as a view? > >Thanks, >Stu From David at sierranevada.com Sat Apr 25 17:08:22 2009 From: David at sierranevada.com (David Lewis) Date: Sat, 25 Apr 2009 15:08:22 -0700 Subject: [dba-SQLServer] Automating view creation In-Reply-To: References: Message-ID: <01606FC26AD0E54B8348D886D0C074D33BF0F3CD69@schwarz.sierranevada.corp> If you are running sqlserver 2005, the following will get you going: select o.name ,o.object_id into #views from sys.objects o join sys.schemas s on s.schema_id = o.schema_id where o.type in ('V') -- and s.name = @schema select definition + char(10) + 'go' + char(10) from sys.sql_modules c join sys.objects o on c.object_id = o.object_id join #views o2 on o.object_id = o2.OBJECT_ID DROP #Views That will give you a result set with the text for the view definition. If you examine it and are happy with it (I don't make any guarantees without knowing more about your db), you have a couple of options: 1) you can place the select statement within a cursor and scroll through #views and execute the statement, which will automatically, so to speak, create the views. A safer way to go is to copy and paste the output of the above into window in ssms, verify it is what you need, and execute the statements one by one. A cursor example might look something like the following (aircode.....) ------------------------------------- select o.name ,o.object_id into #views from sys.objects o join sys.schemas s on s.schema_id = o.schema_id where o.type in ('V') -- and s.name = @schema DECLARE @strSQL VARCHAR(MAX) DECLARE CurB CURSOR FOR select definition + char(10) + 'go' + char(10) from sys.sql_modules c join sys.objects o on c.object_id = o.object_id join #views o2 on o.object_id = o2.OBJECT_ID OPEN CurB FETCH NEXT FROM CurB INTO @strSQL WHILE @@FETCH_STATUS=0 BEGIN PRINT @strSQL --print it to the results window EXEC (@strSQL) -execute it, in this case create the view FETCH NEXT FROM CurB INTO @strSQL END CLOSE CurB DEALLOCATE CurB DROP #Views This will create views, but remember the permissions part of it... -----Original Message----- Message: 1 Date: Fri, 24 Apr 2009 14:00:25 -0500 From: "Robert L. Stewart" Subject: Re: [dba-SQLServer] Automating the creation of views To: dba-sqlserver at databaseadvisors.com Message-ID: <200904241901.n3OJ10eK012020 at databaseadvisors.com> Content-Type: text/plain; charset="us-ascii"; format=flowed Stu, When you right click on a view, you can edit it. When you edit it, you get the SQL script. Change the alter to create. Add the sourcedatabase. where you need to. Right click on the view tab. change the connection to the database you want to save it in. Execute the SQL. There is no way of automating it beyond that. At 12:00 PM 4/24/2009, you wrote: >Date: Fri, 24 Apr 2009 08:14:53 -0500 >From: sdunlap at brownshoe.com >Subject: Re: [dba-SQLServer] Automating the creation of views >To: dba-sqlserver at databaseadvisors.com >Message-ID: > > > >Content-Type: text/plain; charset="US-ASCII" > >Francisco / Betsy, > >Thank you both for your replies. Francisco, I read the article you >provided, but I'm still stuck. I'm able to successfully transport the >results of the View from the source database to a table in the target >database using the SSIS wizard. >However, what I want to do is take a view from the source database, such >as: "SELECT * FROM dbo.MySourceTable WHERE MyField = 'xxx'" > >and create a new view in the target database like this: "SELECT * FROM >SourceDatabase.dbo.MySourceTable WHERE MyField = 'xxx'" > >... or alternatively, I suppose it could be: "SELECT * FROM >SourceDatabase.dbo.MyView" > >Does anyone know of a way to have the view copied into the target database >as a view? > >Thanks, >Stu ******************************************** The contents of this e-mail message and its attachments are covered by the Electronic Communications Privacy Act (18 U.S.C. 2510-2521) and are intended solely for the addressee(s) hereof. If you are not the named recipient, or the employee or agent responsible for delivering the message to the intended recipient, or if this message has been addressed to you in error, you are directed not to read, disclose, reproduce, distribute, disseminate or otherwise use this transmission. If you have received this communication in error, please notify us immediately by return e-mail or by telephone, 530-893-3520, and delete and/or destroy all copies of the message immediately.