sql-server-2008-r2

Retrieve value from csv file and replace it in database in C#

筅森魡賤 提交于 2019-12-12 05:13:21
问题 I am creating an application which reads a csv file into a data grid view in C#. The file consists of data such as item number and stock. If item number is same then its stock should be added and then replace the present stock in the database with same item number. I am able to add stock from the csv file to the database with same item numbers in the database but I am not able to replace stock. Here is my code: string sql_select = "select count(*) from PRODUCTS where item_no= '" + itemNo + "'

SSIS Connection Manager not using the ConnectionString value

↘锁芯ラ 提交于 2019-12-12 04:56:41
问题 I have a child package where the ConnectionString property of a Connection Manager is set by a Parent Package Variable Configuration. I set up a script task that brings up a message box with the value of the ConnectionString property right before the dataflow task. `MessageBox.Show(Dts.Connections["CPU_*"].ConnectionString.ToString());` When I run the parent package, the message box shows that the connection string is changing with every iteration, but in the dataflow it always draws the data

Unlogged out user if power failures/unplugging computer, how to handle power failures

你说的曾经没有我的故事 提交于 2019-12-12 04:53:23
问题 First I have a table UserAccounts with Column LoginStatus if the user logged in the user loginstatus = 1 else if he logged out it is = 0 what code do you think that will handle if the user accidentally plug off the computer or a power failure occurs. i need to change the loginstatus = 0 or it will auto logout if those events occurs. by the way im using sql server i've used this code in form closing but it only change the loginstatus if i shutdown computer from start menu directly while the

Incorrect date comparison results in SQL Server 2008 R2

做~自己de王妃 提交于 2019-12-12 04:48:11
问题 I have a LINQ 2 SQL query that's getting me a list of results for the month of February 2012. The resulting where clause is DECLARE @p0 DateTime = '2012-02-01 00:00:00.000' DECLARE @p1 DateTime = '2012-02-29 23:59:59.999' .... WHERE (CONVERT(DATE, [t0].[DatePlaced]) >= @p0) AND (CONVERT(DATE, [t0].[DatePlaced]) <= @p1) When this runs I'm getting results for 3/1/2012 showing up as well as all the results for 2/2012. If I change the where clause to use BETWEEN then the results only contain

SQL Server BCP Command not Writing NVARCHAR(MAX) Variable Contents to File

允我心安 提交于 2019-12-12 04:45:45
问题 I'm having issues with SQL Server's BCP . I'm not getting an error message but the command is also not writing anything to the path specified. Here is my code: In this scenario, the only variable not accounted for in the code below is @MESSAGE which is a NVARCHAR(MAX) and will take up most of that space so VARCHAR(8000) won't be nearly big enough. DECLARE @OUTPUT_TABLE VARCHAR(255) = '##temp' + CONVERT(VARCHAR(12), CONVERT(INT, RAND() * 1000000)) DECLARE @RESULT INTEGER DECLARE @OUTPUT

Query to copy rows from sql server to another sql server

[亡魂溺海] 提交于 2019-12-12 04:39:15
问题 I have two sql servers, SE1 and SE2, they are basically having the same schema, but each one has its own usability. I need to find a query to copy some rows from SE1.Table1 Where Destination Like '%HR%' to SE2.Table2. Is there such query ?? Thx in advance. 回答1: I find the easiest way is to add a remote connection from one to the other. So, go to the second server and do: sp_addlinkedserver SE1 Then you can go to the database you want to use and do something like: insert into database.dbo

Sum of specific values in SQL

我是研究僧i 提交于 2019-12-12 04:22:25
问题 I'm trying to find the sum of specific values within a table, using SQL. A sample table is: +-------+-------+-------+-------+-------+-------+-------+ | ID | Co1 | Va1 | Co2 | Va2 | Co3 | Va3 | +-------+-------+-------+-------+-------+-------+-------+ | 01 | AA1 | 23.0| AA2 | 11.2| AA3 | 328.34| | 02 | AA2 | 27.0| AA3 | 234.56| AA4 | 23.8| | 03 | AA1 | 409.01| AA4 | 234.98| NULL | NULL | +-------+-------+-------+-------+-------+-------+-------+ I have 35 such 'Code' columns and values. What I

Cannot open database requested by the login. Login failed for user ''

非 Y 不嫁゛ 提交于 2019-12-12 04:18:29
问题 I'm attempting to create a database using a DbContext 'MyDbContext'. I am using SQL Server 2008 R2 with SQL Server and Windows authentication. My DbConfiguration : public class HostDbConfiguration : DbConfiguration { public HostDbConfiguration() { SetProviderServices("System.Data.SqlClient", System.Data.Entity.SqlServer.SqlProviderServices.Instance); SetDefaultConnectionFactory(new LocalDbConnectionFactory("v8.0", @"Server=Eran-PC;MultipleActiveResultSets=True;Trusted_Connection=true")); } }

CTE Index recommendations on multiple keyed table

时光怂恿深爱的人放手 提交于 2019-12-12 04:13:54
问题 I have a View which is keyed on both ChargeID and CustomerID (Charge can be split between multiple customers). The View consists of 2 tables (heavily simplified here, actual tables have ~40 columns each): CREATE TABLE tblCharge (ChargeID int NOT NULL, ParentChargeID int) CREATE TABLE tblChargeShare (ChargeShareID int NOT NULL, ChargeID int NOT NULL, CustomerID int, TotalAmount money, TaxAmount money, DiscountAmount money) The View just joins these both together: CREATE VIEW

Search for a string in all databases, all columns, and all tables (SQL Server 2008 R2)

拥有回忆 提交于 2019-12-12 03:59:20
问题 We suffered some kind of invasion in our SQL Server. I'm trying to find in every database, in every table, every column the word abortion and cheat . I can do this with this query, but in a single database. -- Store results in a local temp table so that. I'm using a -- local temp table so that I can access it in SP_EXECUTESQL. create table #tmp ( db varchar(max), tbl nvarchar(max), col nvarchar(max), val nvarchar(max), ); declare @db nvarchar(max); declare @tbl nvarchar(max); declare @col