sql-server-2005

SQL script to change all table references in all stored procedures

泪湿孤枕 提交于 2021-02-05 09:27:29
问题 I have created a new database with copies of existing tables but changed the names of these tables, is there a SQL script that I can run (maybe using SysObjects) to change all references to these tables in all stored procedures? 回答1: DO NOT RELY ON INFORMATION_SCHEMA.ROUTINES because ROUTINE_DEFINITION is only nvarchar(4000) . You need to sys.sql_modules where definition is nvarchar(max) try any of these to find the procedure that you need to modify: SELECT DISTINCT LEFT(s.name+'.'+o.name,

SQL Server: invalid object name in query execution

南笙酒味 提交于 2021-02-04 22:10:59
问题 I'm trying to execute an Insert statement, but keep getting a Invalid object name error. Here's my code: public string addNewComment(int userID, int pageID, string title, string comment) { string query = "INSERT INTO dbo.nokernok_kommentarer (userID, pageID, commentTitle, comment) " + "VALUES ("+ userID +", "+ pageID +", '"+ title +"', '"+ comment +"')"; adapter.InsertCommand = new SqlCommand(query, connection); //ExecuteNonQuery retuens number of rows affected int numRows = adapter

SQL Server: invalid object name in query execution

僤鯓⒐⒋嵵緔 提交于 2021-02-04 22:04:45
问题 I'm trying to execute an Insert statement, but keep getting a Invalid object name error. Here's my code: public string addNewComment(int userID, int pageID, string title, string comment) { string query = "INSERT INTO dbo.nokernok_kommentarer (userID, pageID, commentTitle, comment) " + "VALUES ("+ userID +", "+ pageID +", '"+ title +"', '"+ comment +"')"; adapter.InsertCommand = new SqlCommand(query, connection); //ExecuteNonQuery retuens number of rows affected int numRows = adapter

SQL Server: invalid object name in query execution

喜夏-厌秋 提交于 2021-02-04 22:04:17
问题 I'm trying to execute an Insert statement, but keep getting a Invalid object name error. Here's my code: public string addNewComment(int userID, int pageID, string title, string comment) { string query = "INSERT INTO dbo.nokernok_kommentarer (userID, pageID, commentTitle, comment) " + "VALUES ("+ userID +", "+ pageID +", '"+ title +"', '"+ comment +"')"; adapter.InsertCommand = new SqlCommand(query, connection); //ExecuteNonQuery retuens number of rows affected int numRows = adapter

In SQL Server 2005, is it possible to set transaction isolation level on a per-user basis?

筅森魡賤 提交于 2021-02-04 18:30:47
问题 In SQL Server 2005, is it possible to automatically set transaction isolation level to, say, read uncommitted an a per-user basis? (So for instance, if I set such a login option for user Fred, Fred wouldn't have to remember sprinkle his select statements with NOLOCK hints or remember to add in a set transaction isolation level statement to his sql.) 回答1: if it is for stored procs you could have code like this in the procs if user_name() in('dbo','username','otherusers','bla') set transaction

Running total for payments to the issued invoices

限于喜欢 提交于 2021-01-29 10:12:57
问题 I have the following tables: create table Invoices (InvoiceID int, InvoiceDate date, Total money); insert into Invoices (InvoiceID, InvoiceDate, Total) values (1,'2020-11-01', 20), (2,'2020-11-01', 14), (3,'2020-11-02', 40), (4,'2020-11-02', 35), (5,'2020-11-03', 10), (6,'2020-11-04', 63), (7,'2020-11-04', 42); create table Payments (InvoiceID int, PaymentDate date, Total money); insert into Payments (InvoiceID, PaymentDate, Total) values (5,'2020-11-07', 10), (6,'2020-11-08', 63), (4,'2020

Insert List(Of Integer) into SQL Server Table [duplicate]

允我心安 提交于 2021-01-29 08:00:26
问题 This question already has answers here : Bulk Insert of Generic List C# into SQL Server (3 answers) Closed 7 years ago . Is there a fast, efficient way in VB.NET/ADO.NET to insert large amount of data from Geneneric.List(Of Integer) into SQL Server table besides looping thru the list and issuing individual INSERT commands? I am limited to .NET 3.5 and SQL Server 2005. Thanks! 回答1: Ship XML with all the changes to a stored procedure. Here is an old example here: http://granadacoder.wordpress

Sequelize/tedious table UPDATE on SQL Server 2005 table with triggers fails

为君一笑 提交于 2021-01-29 04:34:38
问题 Using tedious 1.14 sequelize 3.29 node 6.9.4 Connecting to: SQL Server 2005 on Windows Server 2008 R2 Std Node console output (attempted DML): Executing (default): UPDATE [OtifOrders] SET [onTime]=N'Short Lead Time / Add On',[inFull]=N'Product Substitution' OUTPUT INSERTED.* WHERE [orderNumber] = N'1024098924-1' PATCH /api/otiforders/1024098924-1 500 302.990 ms - - SQL Server error message from profiler: The target table OtifOrders of the DML statement cannot have any enabled triggers if the

SQL Server Timezone Change

£可爱£侵袭症+ 提交于 2021-01-28 08:13:27
问题 I have 2 databases on the same SQL Server. Is it possible to have one in PST and the other in EST? 回答1: No, The date/time is derived from the operating system of the computer on which the instance of SQL Server is running. You could however have a custom UDF that you would call instead of getdate() and then do the timezone change in that UDF. You can also assign default values to columns with something like this CREATE TABLE Test (Val DATETIME DEFAULT dateadd(hh,-3,GETDATE())) Now when you do

Problem with storing images in sql server

早过忘川 提交于 2021-01-28 07:08:48
问题 I am trying to store images in sql server with data type image now the problem is getting stored into two rows, i am using FileUpload control to upload image, my code is as follows byte[] imagedata = ImageUpload.FileBytes; con.Open(); SqlCommand insertImageCmd = new SqlCommand("insert into Images(ImageName,Image) values (@name, @image)", con); insertImageCmd.Parameters.AddWithValue("@name", imageNameTextBox.Text); insertImageCmd.Parameters.AddWithValue("@image", imagedata ); insertImageCmd