Approach To Creating A Procedure That Contains Dll , Dml To Upgrade A System

May 15, 2007

Hi.

I am between beginner and intermediate level of knowledge of sql server.
I am dealing with an sql server 2005 situation (oracle also but thats another
thread/story).

I need to assemble a process that an end user can use easily to update a
database. The update consists of some column lengthening, checks to make sure
new data will fit in columns after the ddl is executed, and then generating
new data (changing primary key column data and keeping all the refering
objects/rows in sync). I also don't want to have an error leave things in a
bad state.

I'm wondering if there is anything special to look out for, and if there are
any suggestions on approach. Here is my current approach:


write a single stored procedure to do all the work.
have it check for existence of table01_bak and table02_bak
delete them if they exist
recreate them

copy table01 and table02 to table01_bak and table02_bak
calculate the new primary key values needed
make sure they will fit (I need to bail out and tell the user to make an
adjustment at this point if they will not)

start a transaction

generate the new primarky key values and insert them
update all the other tables that refer to the still existing primary keys to
point them to the newly generated ones
delete all the old rows using the original primary keys

commit a transaction

delete the table01_bak and table02_bak



thanks
Jeff

Jeff Kish

View 3 Replies


ADVERTISEMENT

Creating System Stored Procedure In 7.0

Mar 14, 2001

Can I create system stored procedure in sql 7.0?
After I used 'alter' to modify a system sp, it's category
change from 'system' to 'user'. Is there way to change it back?
Thanks a lot!

Xiao

View 1 Replies View Related

How To Approach (Trigger-Stored Procedure )

Jul 20, 2005

Hi AllI need opinions on how to approach my task.I currently have 3 tables: the master table, the archive and a temptable.MASTER: has 3 fields ProductID and ProductNo and ReleasedARCHIVE: Has 3 ProductID, ProductNo, SoldDateTEMP: ProductID, ProductNo, SoldDateI have a trigger on the master table upon deletion to archive. This istriggered from a seperate routine from a vb app to delete a recordreal time.CREATE Trigger Archive_Proc On dbo.MASTERFor DeleteAsDeclare @iDate As DateTimeSet @iDate = GetDate()If @@RowCount = 0 Returnset Nocount onInsert Into ARCHIVE(ProductID, ProductNo, SoldDate)Select ProductID, ProductNo, @iDate from deletedMy problem is that I have a temp table that gets filled from aseperate transaction.It needs to be matched against the master tablethen deleted at both master and temp. but the issue is that the temptable contains its own SoldDate value that needs to be archived.Q 1: if I use a stored proc. how do i pass the SoldDate value to thetrigger as Triggers dont use GVs.Q 2: How do I set up the stored procedure to delete with multipletables. I can get it to UPDATE but not delete....CREATE PROCEDURE COMPARESOLD@Pool SmallintASSet NoCount onUpdate MASTERSet Released = 2From TEMP, MASTERWhere TEMP.ProductNo = MASTER.ProductNoAND TEMP.ProductID = MASTER.ProductIDAND INVENTORY.Released = 1hopefully someone can lead me to the right direction...Thanks

View 1 Replies View Related

Setup And Upgrade :: Missing System Administrator

Jun 3, 2015

I am using windows 8 and I have only one user in laptop. While installing SQL 2014, I am getting an error (Missing System Administrator). Under SQL Server Agent and SQL Server Database I have select the system user and gave the password but still I am getting the error.

View 8 Replies View Related

Can SQL Server 2005 Evaluation Be Used To Upgrade A System?

Mar 7, 2006

I have multiple development SQL Servers running Enterprise edition that I want to upgrade for application testing before upgrading our production system. All of the servers meet the hardware and software requirements for SQL Server 2005 Enterprise edition. However, when I try to install to use the SQL Server 2005 Evaluation Edition to upgrade the servers in place, I get the blocked upgrade message:
Name: Microsoft SQL Server 2000
Reason: Your upgrade is blocked. For more information about upgrade support, see the "Version and Edition Upgrades" and "Hardware and Software Requirements" topics in SQL Server 2005 Setup Help or SQL Server 2005 Books Online.
Edition check:
Your upgrade is blocked because of edition upgrade rules. For more information about edition upgrades, see the Version and Edition Upgrades topic in SQL Server 2005 Setup Help or SQL Server 2005 Books Online.

Can the Evaluation Edition be used to upgrade these servers or do you need the full blown version?

thanks

View 4 Replies View Related

Setup And Upgrade :: System Cannot Open Device Or File Specified

May 22, 2013

When I install SQL 2012 onĀ  MS Server 2008 R2, I get this error..The following error has occurred: The system cannot open the device or file specified. Click 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup.

The file in question is Install_VSShell_CPu32_Action. when I retry, the error is..The following error has occurred:SQL Server Setup has encountered an error when running a Windows Installer file.Windows Installer error message: This update package could not be opened. Verify that the update package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer update package. Windows Installer file:

Windows Installer log file: C:Program FilesMicrosoft SQL Server110Setup BootstrapLog20130522_143111VSShell_Cpu32_1.logClick 'Retry' to retry the failed action, or click 'Cancel' to cancel this action and continue setup.

View 7 Replies View Related

Unattended Express Upgrade Changes Service Accounts To Local System

Jan 7, 2008

Hi There

I am doing an unattended upgrade of Sql Express with Advanced Services SP1.
Before the upgrade the services run under domain accounts.
I use the following command :

start /wait setup UPGRADE=SQL_Engine INSTANCENAME=MSSQLSERVER SQLACCOUNT=DOMAINUser SQLPASSWORD=p@ssw0rd ADDLOCAL=Client_Components,SQL_SSMSEE /qn

However after the ugrade the service accounts are running under local system.

Documentation is unclear, i find the following:

; The services for SQL Server and Analysis Server are set auto start. To use the *ACCOUNT settings
; make sure to specify the DOMAIN, e.g. SQLACCOUNT=DOMAINNAMEACCOUNT
; NOTE: When installing SQL_Engine 3 accounts are REQUIRED: SQLACCOUNT, AGTACCOUNT and SQLBROWSERACCOUNT.
; SQLACCOUNT Examples:
; SQLACCOUNT=<domainuser>
; SQLACCOUNT="NT AUTHORITYSYSTEM"
; SQLACCOUNT="NT AUTHORITYNETWORK SERVICE"
; SQLACCOUNT="NT AUTHORITYLOCAL SERVICE"

To my knowledge the <> is not required.
Can someone please help as i cannot get the services accounts to run under a domain user after upgrade.

Thanx

View 1 Replies View Related

Creating System DSN For SQL Server

May 14, 2008

Hello All
how to dynamically create ODBC DSN For SQL Server with SQL Authentication
 
Thanks in Advance
 
Regards
Balagangadharan.R

View 1 Replies View Related

Creating Triggers On System Tables!!

Feb 27, 2002

Does anyone know if it's possible to create a trigger on the sysdatabases table in the master database? I keep getting permission denied which I'm not sure is right.

View 2 Replies View Related

Creating Triggers On System Tables

Mar 1, 2002

Hi,

Does anyone know of a way I can create a trigger on a system table (say sysdatabases in master). I know this is not supported but presumably there's a way it can be done by referencing it's equivilant in Information_schema somewhere.

I'm trying to write a script that will automatically set up a backup schedule for a database that has just been created. I was hoping the trigger would query the sysdatabases table for new database name entries, log necessary info in an audit table and then call a backup script to set up the schedule. Any ideas??

Thanks

Rob

View 1 Replies View Related

Creating System Dsn To SQL Server 2000 Sp 4 Fails

Jul 23, 2007

Hi,



I hope someone can help me out here? I have a fresh install of SQL Server 2000 (standard edition - sp4), on a server running Windows 2003 SE (v 5.2.3790). I am trying to create a system dsn on my client pc (running Windows 2000) to a newly created database in SQL server called BLISS.



I am getting the following error message:



Connection failed:

SQL State :'01000'

SQL Server Error: 11001

[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]Connection Open (Connect()).

Connection Failed:

SQL State :'08001'

SQL Server Error: 6

[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]Specified SQL server not found.



From support.microsft.com I have tried changing the TCPPort value to 0, but this has not helped. Does anyone have any further ideas please?



Jackie

View 5 Replies View Related

Setup And Upgrade :: Creating Alert Which Notifies If Logspace Reaches A Threshold Percentage?

Aug 20, 2015

I want to configure an alert which notifies me if any of my database log files size exceeds a certain threshold percentage.

View 6 Replies View Related

User Provisioning Tool For Vista (creating System Admin Accounts

Apr 8, 2008

I am reading kb 934164. I am confused about (creating system administrator) domain user accounts....
IN SQL 2005 USER PROVISIONING Tools
under kb934164 8e type a window account by the following format
domain/user 8k Type a windows account by following format domain/user
DO I simply type domain/user or do I actually Type my domain/user account
What is domain user?
In other words where does domain (PASSWORD) come from?
where does user(PASSWORD) come from?
I have being trying to find the answer for this
Is there anything else I need to be prepared for in user
provisioning. By the way do you need to turn off uac in vista while installing
sql 2005....Thanks Is there any examples of this? I just want to get it right....

View 6 Replies View Related

Question-Advice Needed: Creating A System To Synch Handheld Entered Data With Main Database.

Jan 30, 2008

Greetings!

I would like to create a database for keeping track of payroll data for employees where the supervisors (job coaches) on our workshop floor can use a Pocket PC device to record the hourly employee data on the fly. Then at the end of the day, the supervisor can place the device in a cradle of some sort and synch the newly entered data into the main database.

I'm guessing that SQL Server Compact edition would be perfect for this type of task? Is that correct? Can someone give me recommendations on how to go about setting this up? What should I use as the main database? SQL Server? Access? Any advice is appreciated!

View 1 Replies View Related

How To Upgrade A Stored Procedure This Way?

Jul 23, 2005

Hi!I need to write a t-sql-script like this:(case-1)IF {stored procedure SP is not exists} BEGINCREATE PROCEDURE SPAS BEGIN//dummy bodyENDENDALTER PROCEDURE SPASBEGIN//real bodyENDand dislike the case below because it is possible that CREATE failsafter DROP and we lost any (old or new) SP versions:(case-2)IF {stored procedure SP is exists} BEGINDROP PROCEDURE SPENDCREATE PROCEDURE SPASBEGIN//real bodyENDHow to write the script lile (1) correctly? Now I have a troubles whileinserting "CREATE PROCUDURE" inside "IF true BEGIN ... END" block.*** Sent via Developersdex http://www.developersdex.com ***

View 1 Replies View Related

T-SQL (Stored Procedure) Upgrade From 7 To 2005

Oct 15, 2006

Hi,I'd like to know if anyone has had experience upgrading their storedprocedures directly from 7 over to 2005, and what issues they've runinto.Also, if there are any articles available on this subject, couldsomeone please point me in the right direction?Thanks!!

View 2 Replies View Related

BCP Call To Stored Procedure - Broke During Upgrade From SQL 7.0 To 2000

Jul 20, 2005

I have this stored procedure that takes a few parameters like date andmerchant ID, and basically goes through a set of if-then statements to builda SQL SELECT string.When we upgraded from SQL Server 7.0 to 2000, the stored procedure stillworked from Query Analyzer, but not in BCP. It used to work in BCP justfine with 7.0. The error I get now is:SQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]BCP host-files must containat least one columnWhat's really strange is, if I instruct the stored procedure to simply printthe SELECT string, then cut-and-paste it into the end of stored procedurecode (assigning it to the variable that already contains the SELECT string),then it works from BCP.Any help would be greatly appreciated.Aston

View 1 Replies View Related

System Stored Procedure

Feb 24, 2005

How can I create a dbo/system stored procedure, not dbo/user SP.
One more thing, if I created a new database TimeDB, I see nothing in stored procedure folder, how can see something (system procedures) as I knew that in SQL 97, we can see something (system procedures).

View 6 Replies View Related

Dt_getobjwithprop_u System Procedure

Feb 14, 2005

Hi All,

Please tell me what this procedure dt_getobjwithprop_u does.

Thanks in advanced,
TN

View 1 Replies View Related

Creating A System.Management Assembly In Order For My Own Assembly To Work?

Aug 2, 2006

Hi

I am a bit paranoid about what I just did to my SQL Server 2005 with this CLR experiment.

I created a Class Lib in C# called inLineLib that has a class Queue which represents an object with an ID field.

in another separate namespace called inLineCLRsql, I created a class called test which will hold the function to be accessed from DB, I referenced and created an instances of the Queue class, and retrieve it's ID in a function called PrintMessage.

namespace inlineCLRsql{


public static class test{


public static void PrintMessage(){



inLineLib.Queue q = new inLineLib.Queue();

int i = q.queueId ;

Microsoft.SqlServer.Server.SqlContext.Pipe.Send(i.ToString());



}

}

}

to access this from the db, I attempted to create an assembley referencing inLineCLRsql.dll. This didn't work as it complained about inLineLib assembly not existing in the db. I then attempted to create an assembley for inLineLib but it barfed saying System.Management assembly not created.

so what I did is (and this is where I need to know if I just ruined sql server or not):

1- ALTER DATABASE myDB SET TRUSTWORTHY ON;.

2- CREATE ASSEMBLY SystemManagement

FROM 'C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Management.dll'

WITH PERMISSION_SET = UNSAFE

3- CREATE ASSEMBLY inLineLibMaster

FROM 'D:inLineServerinLineLibinDebuginLineLib.dll'

WITH PERMISSION_SET = unsafe

4- and finally

CREATE ASSEMBLY inLineLib

FROM 'D:inLineServerCLRSQLinlineCLRsqlinDebuginlineCLRsql.dll'

WITH PERMISSION_SET = SAFE



Everything works after those steps (which took some trial and error). I can create a sproc like:

CREATE PROC sp_test AS

EXTERNAL NAME inLineLib.[inlineCLRsql.test].PrintMessage

and it returns the Queue ID

Is there anything unadvisable about the steps above?



Thanks for your help



M



View 1 Replies View Related

Is Thier Any Procedure To Get System Configuration

Jul 17, 2006

Hi


Is thier any stored procedure to get system configuration
are some give me guide line or stored procedure to get system configuration

View 1 Replies View Related

Using System.IO In A SQL2005 CLR Stored Procedure

Mar 1, 2007

I am attempting to develop a stored proc that will do the following:

1)  Take as an input parameter the filepath of a local directory

2)  Return a recordset showing all files contained in the local directory

At the code level, I am attempting to do the following:

1)  use system.io class to iterate through each file of a given local directory

2)  parse out a union query to show all file names and their system creation times

3)  insert the parsed sql into a sqldatareader, and send that out via a sqlpipe to the caller. 

After compiling and deploying the CLR stored proc, I get the following when I try to execute:

Msg 6522, Level 16, State 1, Procedure spclr_wcl_get_file_info, Line 0

A .NET Framework error occurred during execution of user defined routine or aggregate 'spclr_wcl_get_file_info':

System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

System.Security.SecurityException:

at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)

at System.Security.CodeAccessPermission.Demand()

at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)

at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)

at System.IO.Directory.GetFiles(String path)

at StoredProcedures.spclr_wcl_get_file_info(String str_dir)

This occurs even though I've set the SQL Server service to run as a local administrator on the machine (ie, the account should have full rights to virtually any local directory or file). 

I found the following article which I thought might resolve:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=494009&SiteID=1

but when I include the WindowsImpersonationContext, etc., I instead get the following:

Msg 10312, Level 16, State 49, Procedure spclr_wcl_get_file_info, Line 0

.NET Framework execution was aborted. The UDP/UDF/UDT did not revert thread token.

Was hoping someone could illuminate as to what I'm doing wrong?  Below is a code sample.  TIA.

using System;

using System.Data;

using System.Data.SqlClient;

using System.Data.SqlTypes;

using Microsoft.SqlServer.Server;

using System.IO;

using System.Diagnostics;

 

public partial class StoredProcedures

{

[Microsoft.SqlServer.Server.SqlProcedure]

public static void spclr_wcl_get_file_info(string str_dir)

{

// this clr stored proc will read all files in the trans log directory and return

// a recordset with file names and create dates.

//impersonate the calling user

System.Security.Principal.WindowsImpersonationContext newContext;

newContext = SqlContext.WindowsIdentity.Impersonate();

//enumerate files in directory, use to parse out union select query, return table with file names and create times.

string str_sql = "";

System.DateTime d_date;

FileInfo obj_fsi;

string[] str_arr_files = Directory.GetFiles(str_dir);

foreach(string str_file in str_arr_files)

{

obj_fsi = new FileInfo(str_dir + str_file);

if (obj_fsi.Exists)

{

d_date = obj_fsi.CreationTime;

str_sql += "SELECT CHAR(39)" + str_file + "CHAR(39) AS [file_name], ";

str_sql += d_date.ToLongDateString() + " file_creation_time UNION ";

}

}

// parse off the last 'union'

if (str_sql.Length > ("UNION ").Length)

str_sql = str_sql.Substring(0, str_sql.Length - ("UNION ").Length);

// use sql to send dataset back to caller.

SqlCommand obj_cmd = new SqlCommand();

obj_cmd.Connection = new SqlConnection("Context connection=true");

obj_cmd.Connection.Open();

obj_cmd.CommandText = str_sql;

SqlDataReader obj_reader = obj_cmd.ExecuteReader();

SqlPipe obj_pipe = SqlContext.Pipe;

obj_pipe.Send(obj_reader);

//clean up

obj_reader.Close();

obj_cmd.Connection.Close();

}



};

View 4 Replies View Related

Unable To Get Xml From Query/procedure In Asp, 64 Bit System

Mar 7, 2008

Please help me to get the xml from procedure in asp 64 bit system.
The below code is executed in 32-bit system and display the XML in browser. But if you run the same code in 64-bit system (windows 2003 standard R2) the values replaced with question marks and it it displayed the following error.
I am using SQl server 2000 as a DataBase.

This is very urgent.

Blow is the code with file name test64bit.asp
<%
Dim str_XML
dim cn

set cn = server.createobject("adodb.connection")
cn.ConnectionString = "Provider=SQLOLEDB;User ID=sa;Password=Password;Initial Catalog=northwind;Data Source=SystemName;Network Library=DBMSSOCN;"
cn.Mode = adModeReadWrite
cn.Open

set rsXml = Server.CreateObject("Adodb.recordset")

strSql = "select * from Products for xml auto"
rsXml.open strSql ,cn

while not rsXml.EOF
response.write rsXml(0).value
str_XML = str_XML & rsXml(0)
rsXml.MoveNext
wend

rsXml.close

response.write "str_XML::" & str_XML & "<br>"

%>


Following is the error

?ProductID?ProductName?SupplierID?CategoryID?Quant ityPerUnit?UnitPrice?UnitsInStock?UnitsOnOrder?Reo rderLevel?Discontinued?Products?Al
Microsoft VBScript runtime error '800a000d'

Type mismatch
/ASP/test64bit.asp, line 21

View 2 Replies View Related

System Stored Procedure Question

Jun 27, 2007

Hi,



I'm using the sp_start_job system stored procedure to run a job on the SQL Server Agent. The sp_start_job stored procedure takes a parameter called, step_name where you can begin execution from that step. My problem is that I only want to run that one step of the job rather than that step and every step after it. Is there a way to only execute one particular step? Or a safe way to successfully terminate the process after that step has finished. Any input would be much appreciated. Thanks.

View 4 Replies View Related

System Stored Procedure Call From Within My Database Stored Procedure

Mar 28, 2007

I have a stored procedure that calls a msdb stored procedure internally. I granted the login execute rights on the outer sproc but it still vomits when it tries to execute the inner. Says I don't have the privileges, which makes sense.

How can I grant permissions to a login to execute msdb.dbo.sp_update_schedule()? Or is there a way I can impersonate the sysadmin user for the call by using Execute As sysadmin some how?

Thanks in advance

View 9 Replies View Related

System Stored Procedure Name That Allows One To Change One's Password ?

Jan 2, 2008

I am using a web application using asp.net 1.1 vs 2003.
i am using sql server authentication where users are using their sql server user id and sql server saved passwords.
how can i change their passwords inside the sql server?
is there a system sp that allows one to pass one's user id and then change password.
 I will need to call that sp from a user defined store dprocedure and pass the parameters and that will change the password on the sql server.
thanks
  
 

View 3 Replies View Related

Stored Procedure For Reporting System Issue

Dec 17, 2003

Is it possible to have single stored procedure which can return Weekly, Monthly, Quaterly and Yearly Report.

User input for Queries:
Weekly : Start Date & End Date
Monthly: Month & Year (Eg. Jan 2003, May 2004)
Quarterly: Quarter & Year (First Quarter 2003, ThirdQuarter 2004)
Yearly: Year

Currently I have 4 different Stored Procedure 1 for each reporting system.

I have seen that one can use CASE in Stored procedure.....

Pls give suggestion !!!

View 20 Replies View Related

Another Reporting System Stored Procedure Issue

Jan 2, 2004

Thx to all who helped me for Stored Procedure previously

Here is what I have:
3 Drop Down Boxes:
1) List of property
2) Ticket Status
3) Tech Name

All 3 Drop boxes have default value of "All"

So, if all 3 drop boxes are "All" ie.

list of property = All
Ticket status = All
Tech Name = All

Query pulls up all records from database and displays it.

Lets say if I select Tech Name is XYZ then query should pull out all property, all ticket status by Tech XYZ.

Now my previous developer has if else case and he has total 9 query for doing all this. He has used SQL along with C# code.

I am trying to modify this if-else and convert it into Stored Procedure. Is there a way I can handle all with 1 stored procedure ?

Previous Reporting works like charm........

View 17 Replies View Related

System Stored Procedure Output Into Table

Nov 29, 1999

Hi,
Is it possible to store the output of a SQL Server 7.0/6.5 System Stored Procedure (eg. xp_fixeddrives, sp_spaceused, etc.) in a table, possibly with a Select Into?
All help will be greatly appreciated.
Thanx in advance.
Craig

View 4 Replies View Related

How Can Your Reference Columns In A System Stored Procedure

Nov 5, 2002

I want to have a Stored procedure call another stored procedure gathering the info from some of the information SP#1 and use it calling SP#2...
For example sp_Help returns columns when executed (Name, Owner, Object_type).
So how can I reference the Name column and pass it to SP#2

Exec sp_Help

...?
SP#2 name=sp_help.Name ???


Thanks


Richard

View 1 Replies View Related

Is There A System Stored Procedure That Scripts Tables?

Apr 25, 2007

Hello

I wonder if I can generate the "CREATE TABLE" sentence given the name of a table by means of a stored procedure.

Thanks a lot.

View 4 Replies View Related

System Stored Procedure To Script Table

Sep 30, 2014

Is it possible to access the procedure which scripts a table to new query? My goal is to automate the creation of some tables.

View 4 Replies View Related

Help ---! Procedure To Delete Files From Operating System

Jul 20, 2005

Hi all,Can anyone help me with a script which would delete files ormove them to a different folder at some scheduled time..!Please.....!!!Thanks in advance...

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved