Questions tagged [sql-scripts]

SQL Scripts are lists of SQL sentences written in a single file, meant to be executed sequentially. Depending on the particular RDBMS system, SQL scripts can have procedural language characteristics, such as control-of-flow constructs.

437 questions
2
votes
1 answer

Quickly generate ascii text sql scripts based off of sql 2008 database

This is starting to frustrate me, mostly because it should be easy to do but I can't find anything. I am trying to version control my database. The method I have decided upon is to generate scripts at each check-in that creates a sql script for…
KallDrexx
  • 27,229
  • 33
  • 143
  • 254
2
votes
2 answers

Abort MySQL script conditionally

Given: MySQL database. Sometimes db schema changes and updates are rolled out (in the form of sql script). In order to guarantee correct order of updates applied (no duplicate updates, no updates missing, etc) I plan to deploy the following…
ygrek
  • 6,656
  • 22
  • 29
2
votes
1 answer

Use the default database path to create a filegroup in a script sql server 2008

Quick question, it is possible to include in a SQL Script something like this? IF FILEGROUP_ID('FG') IS NOT NULL ALTER DATABASE [MYDB] ADD FILE (Name=[FG_DATA], Filename='{My default server path}') TO FILEGROUP [FG] GO The idea is to create a…
Ray
  • 483
  • 4
  • 17
2
votes
1 answer

SQL script than create table and and fill it out file Resources.resx

I need to write a sql script that will create a table in the database and populate it with data from the file type Resources.resx As far as I can see, there are only 3 fields: Name, Value and Comment. All string. I using Microsoft SQL Server…
2
votes
1 answer

LINQ's FirstOrDefault in SQL script?

What is the SQL language keyword for the LINQ-to-SQL FirstOrDefault or SingleOrDefault? Is it TOP(1)? EXAMPLE: SELECT TOP(1) @ItemCode = ItemCode FROM VendorItem WHERE VendorId = @VendorId There can't be more than 1 results anyway since there is a…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
2
votes
3 answers

How to work with javax.persistence.sql-load-script-source?

I want to automatically insert data into my MySQL tables. Therefore I try to use the JPA property "javax.persistence.sql-load-script-source" in my persistence.xml:
Benny Code
  • 51,456
  • 28
  • 233
  • 198
2
votes
2 answers

SQL script to add reject reason

On the SQL below it finds "bad rows" in my excel sheet and copies them into another table. This works perfect. However under each OR satement below i want to make the column "rejectionreason" = some error text. So for example if the eventID was = 0…
user1438082
  • 2,740
  • 10
  • 48
  • 82
2
votes
6 answers

SQL Server script: ALTER PROCEDURE - Executing multiple ALTER PROCEDURE into one script without having to select each of the ALTER one after another

I know this is not a big issue, but it tickles me anyway. I have a SQL Server 2005 script to create new data tables, constraints, altering some tables to add columns, altering procedures to take the table changes into account, etc. Everything runs…
Will Marcouiller
  • 23,773
  • 22
  • 96
  • 162
2
votes
3 answers

How to create text file using sql script with text "|"

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…
Yogesh
  • 150
  • 1
  • 4
  • 20
2
votes
2 answers

Operating system error 5(access is denied) when creating Database at Client Machine in C:\ Drive

I am installing SQL Server Express 2005 as a prerequisite of my c# windows form application, and under the Custom Action of my installer class, I'm trying to execute the script below, to create my database on the user machine. However when I choose…
Sunny
  • 618
  • 1
  • 7
  • 22
2
votes
1 answer

Entity framework: ObjectContext get generated SQL change script?

Is there a way to get all the SQL change script of the object context? Note: I am not talking about ObjectQuery.ToTraceString();
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
1
vote
1 answer

Conditionally convert column data type from float to double precision

I have redesigned my Firebird based SQL database. As part of this process I created new table named HARMONICS. Using GUI based administration tool I created following columns: HARM_LP_ID Integer NOT NULL HNUMBER Integer NOT NULL HAMPCHNL0 Double…
truthseeker
  • 1,220
  • 4
  • 25
  • 58
1
vote
1 answer

Logging SQL script errors

I have a SQL script for postgres file with following command. COPY product_master(productId, productName) FROM 'product.txt' DELIMITERS ',' CSV; I want to handle errors of this command (log the error) example ERROR: duplicate key value…
NAC
  • 135
  • 2
  • 11
1
vote
1 answer

Query Help: Totaling parent / child items

[Ed. Note: Related to this SO question; didn't edit question because the problem has fundamentally shifted and question/answers from before are still valid] Looking for advice of how best to create a view. The current query from my previous problem…
SeanKilleen
  • 8,809
  • 17
  • 80
  • 133
1
vote
2 answers

How to change composite key column type from varchar to nvarchar?

I need to change all the varchar columns to the nvarchar type. I've generated a script with the help from this thread SQL Server - script to update database columns from varchar to nvarchar if not already nvarchar. However this script cannot change…
kor_
  • 1,510
  • 1
  • 16
  • 36