sql-server

SQL Server: One Table with 400 Columns or 40 Tables with 10 Columns?

I am using SQL Server 2005 Express and Visual Studio 2008. I have a database which has a table with 400 Columns. Things were (just about manageable) until I had to perform bi-directional sync between several databases. I am wondering what arguments are for and against using 400 column database or 40 table database are? The table in...

Specify expression in LIKE operator

How can specify expression in LIKE operator I want to select all row in table where column Name starts with a-zA-Z followed by # and does not have two dots together (..) i tries this WHERE NAME LIKE '%[a-zA-Z]#' ...

Deploy problem with hierarchyid on automated build only

I am getting the following error during the deploy task of an automated build (Team Foundation Build Server). This deployment may encounter errors during execution because [dbo].[MyTableThatUsesHierarchyId] depends on [sys].[hierarchyid] and [sys].[hierarchyid] does not exist in the target database I can manually deploy ...

How best to do a partial text match in SQL Server 2008

I've a large (1TB) table in SQL Server 2008 that looks something like this: ID int | Flag BIT | Notes NTEXT I need to search every row and set the Flag bit to 1 where Notes contains the word flip Is UPDATE Table SET Flag = 1 WHERE Notes LIKE '%flip%' the 'best' way to do it? I'm thinking that this could take days to run on such a...

Error calling Stored Procedure which executes a .net assembly

I'm getting the following error when trying to execute a stored procedure which calls a .net assembly deployed within a SQL 2005 database: Msg 50000, Level 16, State 1, Procedure usp_GetPrintFilePathandExecPrintJob, Line 63 Error (10314) has occured while executing the usp_GetPrintFilePathandExecPrintJob method. Reason: An error occurre...

How to transfer my data from MS ACCESS DB to a new SQL SERVER DB?

Hello, I have a contact DB that I created 3 years ago in MS ACCESS. After 1 year learning ASP.NET/C#, I'm comfortable witting application now for my office. So, I would like to create the same application in web (using ASP.NET/C#/SQL SERVER) so that anybody in my department can access. Meanwhile, there are at least 127 contacts, prevent...

Issues with Chr(0) in SQL INSERT script

We currently use the SQL Publishing Wizard to back up our database schemas and data, however we have some database tables with hashed passwords that contain the null character (chr(0)). When SQL Publishing Wizard generates the insert data scripts, the null character causes errors when we try and run the resulting SQL - it appears to ign...

Conditional Statements Inside A Where Clause

I have a sproc that runs on many different servers. In the sproc I have a select statement that looks like the following. select * from my_table where id = @my_id and status in (1,3) However, for one of the databases I need the second part of that where clause to only be for statuses equal to 1. So essentially... select * from m...

Parsing excel sheet in C#, inserting new values into database.

I am currently working on a project to parse an excel sheet and insert any values into a database which were not inserted previously. The sheet contains roughly 80 date-value pairs for different names, with an average of about 1500 rows per pair. Each name has 5 date-value pairs entered manually at the end of the week. Over the week...

mdf file is work correctly under App_data folder but after attaching to sql server give following error

mdf file is working correctly under App_data folder but after attaching it to sql server give following error when running asp.net page. Cannot open user default database. Login failed. Login failed for user 'Domain\myUserName'. [edit] More information; SQL data source and connection string. <asp:SqlDataSource id="srcFiles" ...

How to insert a record with only default values?

If I have an SQL table with all default columns (e.g. identity column + any number of columns all with default values), what is the SQL statement to insert a row with no explicit values given? insert MyTable /* ( doh, no fields! ) */ -- values( doh, no values! ) What's the trick? ...

using a non-integer id column in ActiveRecord

Are there any gotchas to using a non-integer column for the id in an ActiveRecord model? We're going to be using replicated databases, with copies of a Rails app writing to those databases in different datacenters. I'm worried that with normal IDs we'll get collisions between newly created rows in different datacenters. Our DBA has su...

Best way of searching through a DataGridView in VB.NET?

Hi peeps, On my form there is a datagridview that may get upwards to about 70k items depending on how scan happy our customers get. I also have a textbox which allows the user to search the datagridview using the textchanged event. I'm using a select statement with the like clause and filling the dataset. I dont think this will cut i...

SQL Join Table Naming Convention

I have 2 tables: Users and Roles, and I have a table that joins these together. The only thing in the join table is Ids that link the 2 tables. What should I call this table? I've never really seen a good naming convention for this. Conventions I've seen before: UsersToRolesJoin UsersToRolesLink UsersToRolesMembership UsersRoles Ex...

Display specific data on asp.net webpage from a microsoft sql express data table

I have been looking around the internet for a way to display specific content from a sql data table. I was hoping that I could display the Content column according to the Id column value. ...

difference between float and [numeric](18, 10)

what's the differece between a sql server type of: float and numeric ...

SQL Server 2005 user prioritization

I currently have a SQL Server 2005 database that is accessed by multiple users. Is it possible to have SQL give processing priority to specific users based on their login names? ie, if Alice and Bob are both running queries simultaneously, I want to ensure that Bob is given priority over Alice. ...

SqlServer performance with a large number of tables in database

I am updating a piece of legacy code in one of our web apps. The app allows the user to upload a spreadsheet, which we will process as a background job. Each of these user uploads creates a new table to store the spreadsheet data, so the number of tables in my SqlServer 2000 database will grow quickly - thousands of tables in the near t...

FOSS version of SQLCompare or something similar?

Actually, free is good enough, it doesn't have to be open source :) I'm currently using the Schema Compare utility of VS2008, but it doesn't have a command line interface and has some other weaknesses as well. I'm wondering what free tools others are using to provide command line schema comparisons/synchronizations? Thanks. ...

Swapping two DB rows without violating constraints

I have a table regionkey: areaid -- primary key, int region -- char(4) locale -- char(4) The entire rest of the database is foreign-keyed to areaid. In this table there is an index on (region, locale) with a unique constraint. The problem is that I have two records: 101 MICH DETR 102 ILLI CHIC And I need to swap the (r...