Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Thursday, March 29, 2012

Embedding multiple .sql files

How do I write a .sql script that executes a number of other scripts in .sql
files? This has to be easy. I just can't find it.
Thanks,
JerryRYou can use oSql. See if this helps:
http://www.sql-server-performance.com/rd_osql.asp
Andrew J. Kelly SQL MVP
"JerryR" <JerryR@.discussions.microsoft.com> wrote in message
news:76549937-4F1E-41B5-B148-A548F0B8CA95@.microsoft.com...
> How do I write a .sql script that executes a number of other scripts in
> .sql
> files? This has to be easy. I just can't find it.
> Thanks,
> JerryR|||There is no such feature in SQL like this in Oracle @.Somefile.sql. You
have to put in in a OS batch to execute it via a cmdshell program like
SQLCMD or OSQL or ISQL.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--|||Yes, that's what I was looking for.
Thanks
"Jens" <Jens@.sqlserver2005.de> wrote in message
news:1143927815.456011.236990@.v46g2000cwv.googlegroups.com...
> There is no such feature in SQL like this in Oracle @.Somefile.sql. You
> have to put in in a OS batch to execute it via a cmdshell program like
> SQLCMD or OSQL or ISQL.
>
> HTH, Jens Suessmeyer.
> --
> http://www.sqlserver2005.de
> --
>

Friday, March 9, 2012

EM SQL Scripts

The EM can produce SQL Scripts of tables/indexes/constraints/default values etc from a database. When doing so, the create statement for tables and the alter statements for constraints (including the default values) are separated. In effect, the create table-statement will only create the table; keys, default values, indexes are changes on the table. My question is: when saving the results in separated files as a basis to continue working on, would you take the effort of changing the create-tables statements so that will also fill in the default values or keep it separate?I've never bothered to mangle the generated scripts... I've never seen any need for it.

-PatP|||Pat: Thing is, there's a db here without any of the tables/views/sp's stored on disk making it, imho, an unhealthy basis to continue building on. So I've scripted the db layout, views and all that allowing me to create a dev. I'm just considering whether I should take the effort or not; when changes are made to the db/tables I'll process it into the create-scripts as well.
I wonder though, do you have any create scripts that create all the tables in a database, do you keep it separate from the indexes/constraints? I don't want to start a flame-thing on "who's responsible", just wondering if you'd take the trouble?|||I'm not really clear what you are asking, so this response may seem way off base.

If you are talking about the option that causes Enterprise Mangler to script the PK/FK/Default/Check Constraints as part of the table versus scripting the table "raw" then creating ALTER TABLE statements to add the constraints, I usually don't care how it gets done. If there was some compelling reason to set it one way or the other, then I would. Since the net effect after running the whole script will be the same, I've never bothered to monkey with it... Either way works fine for me, and produces the same results in the end.

-PatP

Wednesday, February 15, 2012

Editing USers in Enterprise Manager

Help!
We use application scripts to set up and modify users in
SQL. We are using SQL and Windows authentication. Very
occasionally, a script will fail and I will have to go in
and modify a user account directly from EM. I have done
this many times over the last 18 months and never had an
issue with it. I use the SQL Server Login Properties
dialogue box accessed from Security/Logins in EM.
Today, after I had made my changes and clicked okay, I was
immediately prompted with the "Confirm Password Change"
box. I double and triple checked (by re-executing the
task) that I had NOT in fact changed the password; I still
get the warning box. Even when I enter the CORRECT
password for the user, SQL EM warns me that the passwords
do not match and refuses to update the user account.
When I deliberately change the password and confirm the
change at the prompt, then EM accepts the changes and
proceeds.
What's going on? I tested this on three identically
configured servers and had the same results each time.
I am running:
1. SQL Server 2000 (SP3, with the latest security patch
released in July)
2. Windows 2000 Server (SP4, with the latest security
patches release in July)
3. I tested and found the problem with both Developer
Edition and Enterprise edition SQL Server.
The work-around that I have found was to go into the
Logins section for the database and make the updates
there. Note, however, that I cannot edit certain server-
wide roles in that section.
Regards,
Hugh ScottFIX: You Are Prompted for Password Confirmation After You Change a Standard
SQL Server Login
http://support.microsoft.com/?kbid=826161
--
HTH
Jasper Smith (SQL Server MVP)
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Hugh Scott" <hugh.scott@.exel.com> wrote in message
news:05e901c365ce$7ef1a5a0$a101280a@.phx.gbl...
Help!
We use application scripts to set up and modify users in
SQL. We are using SQL and Windows authentication. Very
occasionally, a script will fail and I will have to go in
and modify a user account directly from EM. I have done
this many times over the last 18 months and never had an
issue with it. I use the SQL Server Login Properties
dialogue box accessed from Security/Logins in EM.
Today, after I had made my changes and clicked okay, I was
immediately prompted with the "Confirm Password Change"
box. I double and triple checked (by re-executing the
task) that I had NOT in fact changed the password; I still
get the warning box. Even when I enter the CORRECT
password for the user, SQL EM warns me that the passwords
do not match and refuses to update the user account.
When I deliberately change the password and confirm the
change at the prompt, then EM accepts the changes and
proceeds.
What's going on? I tested this on three identically
configured servers and had the same results each time.
I am running:
1. SQL Server 2000 (SP3, with the latest security patch
released in July)
2. Windows 2000 Server (SP4, with the latest security
patches release in July)
3. I tested and found the problem with both Developer
Edition and Enterprise edition SQL Server.
The work-around that I have found was to go into the
Logins section for the database and make the updates
there. Note, however, that I cannot edit certain server-
wide roles in that section.
Regards,
Hugh Scott