sql-server

SQL Server: finding the bad data

How do I select all rows except for ones that where I get an error calling CONVERT on one of the columns? For example, I am doing this: SELECT rowid FROM batchinfo WHERE CONVERT(DATE, reporttime, 101) between '2010-07-01' and '2010-07-31'; And I am getting errors for some of the values. I have two questions: How can I skip the r...

stored procedure returns varchar in LINQ

I would like to know if in SQL is it possible to return a varchar value from a stored procedure, most of the examples I have seen the return value is an int Example within a proc declare @ErrorMessage varchar(255) if @TestFlag = 0 set @ErrorMessage = 'Test' return @ErrorMessage calling on asp.net Updated: Error: Conversion fai...

How can I edit values of an INSERT in a trigger on SQL Server?

I have the table Tb ID | Name | Desc ------------------------- 1 | Sample | sample desc I want to create a trigger on INSERT that will change the value of the inserting Desc, for example: INSERT INTO Tb(Name, Desc) VALUES ('x', 'y') Will result in ID | Name | Desc ------------------------- 1 | Sample | sample desc 2 | x ...

Why would a Stored Procedure run slower than naked T-SQL?

I have a stored procedure in a MS-SQL 2005 database that: Creates two temp tables Executes a query with 7 joins but is not otherwise terribly complex Inserts the results into one of the temp tables Executes two more queries (no joins to "real" tables) that puts records from one of the temp tables into the other. Returns a result set fr...

Stuck: SQL Server + Rails + Mac OS X

I am having an insanely tough time getting Rails to connect to SQL Server on a Mac. I have set up a DSN using Actual SQL Server drivers: http://www.actualtech.com/ - it works great. I can test it and it seems to be functioning. However, when I run: iodbctest "dsn=rails_import2;uid=sa;pwd=mypassword" The output is: 1: SQLDriverConn...

Python client for MSSQL, with encrypted connections?

I am looking for a Python client for MSSQL, but one that supports encrypted connections to a remote MSSQL server. Can someone recommend a technique for using Python to read from MSSQL, over an encrypted connection? ...

Opinions/expertise/suggestions wanted - provide feedback from php performing a lengthy task

I am thinking about converting a visual basic application (that takes pipe delimited files and imports them into a microsoft sql database) into a php page. One of these files is on average about 9 megabytes in size. (I couldn't be accurate about the number of lines involved but I'd say it's about 20 thousand) One of the advantages bei...

Configure ADP application to use a different database...?

I have an Access Project (ADP) that is currently configured to connect to an SQL Server 2000 database on one server. I now need to migrate that server to SQL Server 2008 that will be on a different server. I've not developed in Access for a while and have not done anything like this before... Is it just a simple matter of modifying a ...

My T-SQL query needs additional SUM's from an additional table...

The following is my current query. It works the way i want it to. However, it needs some improvements so that i can 1) retrieve the SUM's of the money columns in my 'expenses' table and 2) add a WHERE clause (or HAVING?) so that all of the SUM's are year-to-date values, e.g. any amounts prior to Jan. 1, 2010 will not be totaled by the SU...

Database Design Help: Whose kid is this anyway...

I am building my wife a Contacts Manager program as a fun exercise in learning Silverlight 4. It will track peoples Addresses, Phone Numbers, Emails, Special Occasions(Birthday, Anniversary, etc) Along the way I hit a minor road bump while designing the Database. She would like to be able to group Contacts(people) by Family so I creat...

SQLServer: Problem choosing a default schema for a user

I named a schema wrong, and all the tables are created with a schema of a wrong name. So I created a one, and use alter schema to transfer the tables over. First problem is, SQL Server fails when I try to drop the wrong schema, second, although users were created with the new schema as default, I figure I could simply say select * fr...

SQL Filtering A Result Set To Return A Maximum Amount Of Rows At Even Intervals

I currently use SQL2008 where I have a stored procedure that fetches data from a table that then gets fed in to a line graph on the client. This procedure takes a from date and a too date as parameters to filter the data. This works fine for small datasets but the graph gets a bit muddled when a large date range is entered causes thousen...

SQL Server Select on Different column

Hi All, I want to select a value based on different column in SQL Server, say Result = Isnull(A.OUT1,'')<>'' then select A.OUT1 Isnull(A.OUT2,'')<>'' then select A.OUT2 Isnull(A.OUT3,'')<>'' then select A.OUT3 How to form query to get the Result? ...

update null for type date

I have a sentence follow: string strSQL = "update pl_poli set ag_vouch = ' ',ag_vdate = #, ag_vmode = null where pl_no = '" + textBox5.Text + "' and pl_endtno ='" + textBox6.Text + "'"; I can't update because error "data type mismath". i have fill ag_vdate is type date I want to Update it -> null Please can you help me. Thank you...

Returning first instance of value across multiple tables (and returning associated columns)

I am looking to return the following information for each contact contained within a set of tables: Contact_id | first_Event_date | first_Event_id | event_type id123456 | 01/12/2007 | eveid123456 | table1 id456455 | 05/06/1999 | eveid456585 | table4 Where the data reflect...

Login failed for user ''.

I have a an ASP .Net MVC website which works fine when testing locally. I have put the website onto IIS 7 on our windows server 2008 machine. The website uses .net membership provider and when I try to login I receive the following error: Login failed for user ''. This is the membership connection string: data source=(local);Integr...

SQL Server 2005 and 2008 in conjunction

Is it recommended to use two versions of SQL Server (2005 and 2008) for storing data of an application. We have a situation where we have an existing web application consuming SQL server 2005 as a database. Some enhancements in the application required us to solution a FILESTREAM data store. Now we have our data in SQL Server 2005 and as...

MySql and MsSQl backup with code

I try to back up from MySQL with codes. Is it possible? If it will possible, I could use this code getting backup from MsSQL. Thank a lot. ...

Splitting Address Lines in MS SQL

Hi guys, I have this setup: an output table where my results will end up consisting of [FirstName] [LastName] [Address1] [Address2] [Address3] [ZipCode] [City] [Country] The original data consists mostly of line feed split address lines, some are split by commas, and there is one name field. My original data tables look simply like...

login failed for user 'sa'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452) in sql 2008

Hi so make quick: i use windows 7 ultimate. I can login with windows authentication mode but sql authentication with user 'sa' don't work!. sa user is enable so what do i do? ...