sql-server

How to strip "()," from Python, PyODBC, SQL Returns?

Hi, I grabbed a bunch of SQL IDs I need to update with Python and PyODBC: import pyodbc cnxn = pyodbc.connect('DSN=YesOne;PWD=xxx') cursor = cnxn.cursor() cursor.execute("SELECT ID FROM One.dbo.Two WHERE STATUS = 'OnGoing' AND ID = ''") I have a second bit of code that updates the IDs: cursor.execute("Update One.dbo.Two SET STATUS =...

How to pass values to a view in sql server

I have created a view called business this runs sucessfully ,but the problem is how will i use dynamic values in place of 12.925432,77.5940171 ,I want to pass parameter in sql query from c# code behind. create view [dbo].[business] as SELECT Id, Name1, ZipCode, StreetName, StreetNumber, State1, ...

SQL queries exceedingly slow when referencing primary key

I have a MS SQL table with about 8 million records. There is a primary key (with clustered index with only 0.8% fragmentation) on the column "ID". When I run seemingly any query referencing the ID column, the query takes very long (and in fact ultimately crashes my application). This includes simple queries like "SELECT * FROM table WH...

How do i get top n records of each category

Hi guys, I am here to get records based on categories. My table foo has fields [id, name, class]. my records can be like: 1, ram, 10 2, hari, 9 3, sita, 10 4, gita, 9 5, rita, 5 6, tina, 7 8, nita, 8 9, bita, 5 10,seta, 7 ...and more... Now i would like to get result with each record from different class.. i.e something like 1, r...

SQL 2000: Variables in update statements and order of evaluation

I have an update statement in this form: declare @v as int update tbl set @v=tbl.a=(select sum(amount) from anothertable at where at.x = tbl.y), tbl.b = @v/2 The reason I would like to use a variable is to avoid using the subquery twice. The problem is that I have not found any references stating that this is safe. Is the second a...

SQL DECIMAL column that supports and converts empty OR spaces into NULL

I have a DECIMAL field in my SQL table, and I want to support EMPTY and SPACES as well. So, when the user enters nothing OR spaces only in that field, I still want the table to take it and convert that into NULL. I tried using CASE in an INSERT statement, in SQL. I am using it under PHP. I tried this: INSERT INTO test (id,value) VALUES...

Qt, MySQL server has gone away

Here my code snippet: query.next(); qDebug()<<query.lastError(); qlonglong res=query.value(0).toLongLong(); qDebug()<<query.lastError(); and the corresponding log I have: Debug: QSqlError(2006, "QMYSQL: Unable to execute query", "MySQL server has gone away") Warning: QSqlQuery::value: not positioned on a valid record Debug: QSqlErro...

Simultaneous connections to SQL Server using the same name and password. Is there any problem with that ?

// MS SQL Server 2008. My application has several different connections to sql server database (C#, ADO .NET). Each connection uses the same user name and password. Some connections may execute simultaneously. Is there any problem with that ? Should I add some settings to support that functionality ? Is there any settings in connectio...

Save Update attempts in temp table in Update Trigger

The query is - how to Save Update attempts in temp table in Update Trigger ...

Report Server Model

Hi I have created a Report Server models and 50+ Reports working off the Model. Now that I have pointed the model to a Live database, I have noticed it limits the results. I can't seem to see data before 2009! Has anyone had this issue and is there a way to get my model to show the data I want? I have done an Explore Data on my table...

SQL Server: how to change login

I have many users in one database. All these users are named using "domain\" as a prefix. I would like to rename these user names by dropping this domain name from the user name. How to do that? In SQL Server Management Studio GUI user name is grayed and cannot be changed? ...

How do i call a stored procedure with parameters from c# code behind

I have created a stored procedure shown below ,how will i call this from c# code behind to get the result and results are stored in dataset. USE [Test] GO /****** Object: StoredProcedure [dbo].[tesproc] Script Date: 09/01/2010 13:00:54 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[tesproc] -- A...

sql server importing excel data with merge cells

hi, i have a set of excel data containing merge cells that needs to be imported into sql server. However, the results of import show null for cells that are merged. i have tried using IMEX function, testing with values 0,1,2. but it still imports merge cells as null. is there a way to this? thank you SELECT * INTO BenchmarkSurvey FROM...

How to stop stored procs from whining about a missing column that I am about to delete in SQL Server 2008?

Hi all, I am deleting a column from one of the frequently used tables in my database. Last time I did this errors started to crawl up from all sorts of stored procs that I had long forgotten existed; complaining about the missing column. (only when that stored proc was called) so, I dont want to get winded up with these things again,...

SQL Server: COLLATE CS->CI performance vs UPPER

What's better to use when comparing columns that could contains values with different cases? Is Collate faster? Just trying to figure this out because in our project with tons of data comparisons. we use: select * from table t1, table t2 where t1.col1 collate SQL_Latin1_General_CP1_CI_AS = t2.colb collate SQL_Latin1_General_CP1_CI_AS ...

inner join Vs Function

Hi all, Which of the following query is better... This is just an example, there are numerous situations, where I want the user name to be displayed instead of UserID Select EmailDate, B.EmployeeName as [UserName], EmailSubject from Trn_Misc_Email as A inner join Mst_Users as B on A.CreatedUserID = B.EmployeeLog...

SQL change query to show orphans

Give the query: SELECT tblProducts.ID, tblProducts.views, tblProducts.productName, tblProducts.isForSale, tblProducts.isLimitedStock, tblProducts.stockCount, tblProducts.description, tblProducts.weightKG, tblProducts.basePrice, tblProducts.dateCreated, tblProductCats.catName, (SELECT COUNT(*) FROM tblProductPrices WHERE product...

how to find min selling price record in sql server 2008?

ProductPrice table: ProductPriceId,ProductId,CurrencyId,CustomerGroupId,PriceTierId,List,Selling,Bulk 868 1 1 NULL NULL 45.00 42.00 42.00 869 1 1 2 NULL 39.00 36.00 33.00 870 1 3 NULL NULL 48.00 45.00 45.00 871 ...

How to create a view and select from it in one SINGLE query execution

I want to create a veiw and then select from it in one query, would you please tell me how it is possible the code below: create view myView as select [Order Details].Discount from [Order Details] select * from myView if i want to run the code, first i have to select that part which is related to creating a view and then i have to sel...

SQL Express 2008 R2 Installation problem (getting error in silent installation)

Hi, I create install script that will install my application and also "Microsoft SQL Server Express 2008 R2" (32 BIT) engine + Advanced tools (without the Management Studio). It been installed successful on Windows XP SP3 but on windows 7 i get an error. The full logs and Setup configuration are in the link files below. I will be grate...