sql-server

What are ways to match street addresses in SQL Server?

We have a column for street addresses: 123 Maple Rd. 321 1st Ave. etc... Is there any way to match these addresses to a given input? The input would be a street address, but it might not be in the same format. For example: 123 Maple Road 321 1st Avenue Our first thought is to strip the input of all street terms (rd, s...

Creating and looping through a list in an sql server stored procedure

Is there a way to declare a list of items in an sql server stored procedure using T-SQL and then loop through the items? I'm trying to do something like this: input_string = 'my dog has fleas.' list_remove = 'a', 'e', 'i', 'o', 'u' for each item in list remove input_string = replace(input_string, item, '') end And in the end inp...

Fetch the row which has the Max value for a column in SQL Server

I found a question that was very similar to this one, but using features that seem exclusive to Oracle. I'm looking to do this in SQL Server. I have a table like this: MyTable -------------------- MyTableID INT PK UserID INT Counter INT Each user can have multiple rows, with different values for Counter in each row. I need t...

Bind WPF control to SQL server through repository pattern

How can I bind a wpf control to a SQL Server property. Like say a Listbox <ListView> <ListView.View> <GridView> <GridViewColumn Header="Name"> <GridViewColumn Header="Date Assigned"> <GridViewColumn Header="Date Due"> </GridView> </ListView.View> ...

SQL Server Reporting Services 2005 - How to Put a Conditional Total in a Header Row

Let's say I have a table like this: Customer,Invoice Type,Balance A,Good,50 A,Good,10 A,Bad,20 B,Good,20 And I want to make a report like this: Customer,Invoice Type,Balance,Total Adjusted Balance A 40 Good 50 10 Bad 20 B 20 Good 20 Where total adjusted bal...

SQL Server 2008 CLR vs T-SQL: Is there an efficiency/speed difference?

I'm a C# developer who has done some basic database work in T-SQL. However, I need to write a very complicated stored procedure, well above my T-SQL knowledge. Will writing a stored procedure in C# using the .net CLR as part of SQL Server 2008 cause my stored procedure to be less efficient than if it were written in T-SQL? Is the differ...

Legitimate uses of DUMP TRAN

I recently had to root out the cause of intermittent ODBC errors in a 12 year old SQL Based application. The culprit turned out to be this statement at the end of one of the stored procedures: DUMP TRAN NotTheRealDBName WITH NO_LOG I wasn't familiar with this command, so I did some research and found that it makes a backup of the tra...

move selected data from one server to another sql server 2008

i need to move selected data from 800+ tables in one database to the same 800+ tables in another database in another server. The data i select is based on date fields of every table. So, if i say table 1 date from 01/01/10 to 01/15/10, then only that data i want to be copied into the other server's database table specified. i hope i am n...

Graphical Interface for adding users to aspnet_Membership and aspnet_Users etc

Hi everyone, This might be a pretty basic question, but how do you add new users to the aspnet_Users table in a ASP.Net 2.0 app? I know I could do it using a SQL script, and being mindful of the associations, but I know I've seen a graphical interface for it... I can't find code for adding new users in the web app I'm maintaining (it ...

SQL Server 2005 express connection with Visual Web Developer 2008 express.

Ok so I had first downloaded SQL Server Express 2008 and Wed Developer Express 2008, and I could not integrate the two together. Was getting error messages that were wasking for the correct version of SQL Server 2005, so.... I uninstalled SQL Server Express 2008, and installed SQL Server Express 2005. Now I open the Visual Web Develope...

.net publish to prover creates 'unwanted' role.

I am using the publish to provider feature in .net 2008 to produce a database creation script. In the script exists the following line: /****** Object: Role [srvTTAS] Script Date: 01/20/2010 09:14:14 ******/ IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'srvTTAS') BEGIN IF NOT EXISTS (SELECT * FROM sys.databas...

SQL Server 2005 - Setting a column as readonly

I have a "InsertTime" field in a table in a SQL Server 2005 database which is defaulted to "getDate()" when the record is first inserted into the database. I want to ensure that this column is not updated again. Can this column be set to readonly or is there a better way to do this without writing all of the sql for the developers? ...

SQL Server: How to use Cursor to delete records

Hi guys: We want to remove tons of obsolete data in a table, but this will lock table for a long while. Is is possible to use Cursor to delete, says, one hundred records per transaction in a while-loop ? And where can I refer to the example? ...

How to switch from SQL Server to MySQL for using with Excel pivot

I have a table that contains sales transaction (~20 mil rows). Previously I used SQL Server and export it to an Excel pivot. Data refresh took 10-15 minutes but still do-able. However, after I migrated to MySQL (using XamppLite & ODBC), it took forever to refresh the data in the Excel pivot. Maybe I didn't optimize the MySQL good enough...

SQL Server Reporting Services 2005 attempts to store credentials fail

I'm trying to figure out which credentials I should be storing to enable use of Reporting Services' Data-Driven Subscriptions. Nothing I type in seems to work. It's all happening on localhost under XP-Pro SP3. A little background: I'm able to connect to the localhost server as a Database Engine in SQL Server Management Studio, using ...

looping in stored procedure

how to do looping process inside stored procedure to insert max number of records ...

SQL Server 2005 deadlock with nonclustered index

Hello, Can anybody help me for a deadlock in SQL Server 2005? For a simple test, I have a table "Book" which has a primary key (id), and a column name. The default index of this primary key is nonclustered. The deadlock happens when two sessions run at a same time. Activity monitor shows the first session "//step 1" locks the row(rid...

What are the binary storage formats for sqflt8, sqlmoney and other native SQL data types?

According to the documentation, native (binary) data can be imported or exported with bcp formatted in the native SQL Server data formats. Examples of these are SQLFLT8, SQLFLT4, SQLMONEY or SQLNUMERIC. Does anyone know either what the data formats for the various types are, or where documentation specifying these formats might be foun...

Sql code formatter for .NET (SQL Server 2008 dialect)

Can you please point me to a an SQL code formatter, preferably as an opensource library for NET? I need to make sql source code invariant to the formatting, because i would like to make consistent diff on version control system merges, and it's not easy to maintain in generated code mixed with snippets of handcrafted code. My idea is t...

Axapta database documentation

Hi, i'm trying to export data from Axapta database (Ms Sql Server 2000). Exists any documentation for this database? Thanks a lot ...