sql-scripts

How do I set a SQL Server script's timeout from within the script?

余生长醉 提交于 2020-01-20 04:54:45
问题 I have a large script file (nearly 300MB, and feasibly bigger in the future) that I am trying to run. It has been suggested in the comments of Gulzar's answer to my question about it that I should change the script timeout to 0 (no timeout). What is the best way to set this timeout from within the script? At the moment I have all of this at the top of the script file in the hopes that one of them does something: sp_configure 'remote login timeout', 600 go sp_configure 'remote query timeout',

Generating scripts based on condition

折月煮酒 提交于 2020-01-05 09:08:32
问题 The inserts of a certain table(s) can be generated by using SQL Server Management Studio by right clicking on the database -> tasks -> generate scripts, choosing the tables and finally selecting data only. However the table gets bigger with time and I need only the inserts with a certain condition which would only return only a part of the data in that table. Example: there is a table FlightTickets ( TicketId(PK), BuyerId(FK to buyers), FlightId(FK to Flights) ) and I only need the insert

Generating scripts based on condition

核能气质少年 提交于 2020-01-05 09:08:07
问题 The inserts of a certain table(s) can be generated by using SQL Server Management Studio by right clicking on the database -> tasks -> generate scripts, choosing the tables and finally selecting data only. However the table gets bigger with time and I need only the inserts with a certain condition which would only return only a part of the data in that table. Example: there is a table FlightTickets ( TicketId(PK), BuyerId(FK to buyers), FlightId(FK to Flights) ) and I only need the insert

How to run an SQL script against a MDF file?

别来无恙 提交于 2020-01-03 09:25:14
问题 I've created a database model with model-first method using Entity Framework 4.0. I then created an sql script using the Generate Database from Model... I've also created an SQL Server Database file in my App_Data folder. How do I now run the SQL file against this MDF file? I'm using Visual Studio 2010. 回答1: I ran into this same problem and here is what worked for me. When I selected "Generate Database from Model..." I created a new MDF file. This process worked fine and Visual Studio

How to create text file using sql script with text “|”

大憨熊 提交于 2019-12-29 01:29:34
问题 if i run below script without char "|" it working but when i am adding char "|" it is not working how to add char "|" using sql script to text file ? DECLARE @Text AS VARCHAR(100) DECLARE @Cmd AS VARCHAR(100) SET @Text = 'Hello world| ' SET @Cmd ='echo ' + @Text + ' > C:\AppTextFile.txt' EXECUTE Master.dbo.xp_CmdShell @Cmd thanks 回答1: The pipe character has a special meaning in batch commands, so it must be escaped using the caret character. This should work: DECLARE @Text AS VARCHAR(100)

Condition based spool generation in Oracle SQL script

孤者浪人 提交于 2019-12-25 02:46:11
问题 I have a scenario where we generate spool based on condition. The spool should generate only if user types y. column col noprint new_value elcm_script select decode(lower('&gen'),'y','C:\ELCM.SQL','n', 'null') col from dual; SPOOL c:\ELCM_DETAILS.SPL @&elcm_script spool off In the above it will generate spool file even if user type n like error reading file.. How to stop generating the spool if n.or how to remove spool which is generated/ 回答1: If you can put this controlling section into its