sql-server

Search column in SQL database ignoring special characters

Hi, Does anybody know if it's possible to do a %LIKE% search against a column in a SQL Server database but get it to ignore any special characters in the column? So, for example if I have a column called "songs" and they contain the following... Black Or White No Sleep 'till Brooklyn The Ship Song Papa Don't Preach If the user...

Update SQL table with random value from other table

Hi On Microsoft SQL Server 2008, I have a table with Products: Id | Name | DefaultImageId And one with Images: Id | ProductId | Bytes I want to run an Update statement, that updates the DefaultImageId on all records in the Products table with a random Id from the Images table that is related to the Product via the ProductId column. ...

SQL Server 2005 truncates strings at double quotes

When I update the pollQuestion and pollName column that contain double quotes using the stored proc below, it saves the double quotes properly. However, for columns option1,...,option9, the stored proc doesn't save the double quotes or any characters after the double quotes. It's as though SQL Server truncates the string prematurely at t...

How to search for a specific string in all columns within all tables of a SQL Server database?

We want to search for a string (ie. "Hello World") in all our database that has about 120 tables. We thought about doing a dump like mysql dump but it came out in a weird bak format. The search should be done in each column for each table. Is this possible with any type of script, or this is harder than it sounds to me? ...

How to create a Foreign Key with "ON UPDATE CASCADE" on Oracle?

In MS SQL Server it is possible to create a foreign key with ON UPDATE CASCADE option, so whenever you update one of the columns in the primary key, the foreign keys in other tables will also be update by the DBMS. So, how to do it in Oracle? ...

Is SQL Server Naming trailing space insensitive?

I have a Location table in my OLTP which, while coding SSIS against it, I found a LocationCode column name to have a trailing space in it. Create Table Location ( [LocationId] INT IDENTITY (1, 1) [LocationCode ] INT ) Note that LocationCode column name has a trailing space. And yet, the following code works. SELECT LocationC...

Analyzing time-dependent, event log from SQL

I have an event log in a SQL Server database. Essentially it records when a call was made and when that call ended at a call center (as two different records), as well as a few other details. I am trying to get an idea of how many phone lines are being used at any given time with this data. I can't think of any good way to have a SQL que...

SELECT with calculated column that is dependent upon a correlation

I don't do a lot of SQL,and most of the time, I'm doing CRUD operations. Occasionally I'll get something a bit more complicated. So, this question may be a newbie question, but I'm ready. I've just been trying to figure this out for hours, and it's been no use. So, Imagine the following table structure: > | ID | Col1 | Col2 | Col3 |...

What SQL Server 2008 Edition can I fly with?

Hello, I have designed an ecommerce software suite that I am going to be hosting for multiple sites (20-50) on a single Virtual Dedicated Server. (64-Bit, machine that has 960 MB of RAM) Each site has its own database. I plan to install SQL Server 2008 however I am not sure which version is best. I would like to start with the free expr...

Multiplying a Column by -1 Based on Another Column

I'm writing an SSRS report that will change the value of one of the fields based on the value of another field in the same row. Would the best way to do it via SQL? i.e.-Multiply FieldX (float) by -1 if the value of FieldY ends with D,DA, or 'DB', etc. I was initially looking at using a case statement, however I was getting a little s...

SOME in T-SQL: how to use it?

SELECT * FROM VNTREAT WHERE VN = SOME ('482') Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '482'. ...

Insert results of subquery into table with a constant

The outline of the tables in question are as follows: I have a table, lets call it join, that has two columns, both foreign keys to other tables. Let's call the two columns userid and buildingid so join looks like +--------------+ | join | |--------------| |userid | |buildingid | +--------------+ I basically need to...

Why is this SQL statement very slow?

Hi, I've got a table with about 1 million records (running SQL Server 2008 Web). I've got a search routine which tries to match on product code as well as product description. However in some circumstances it's very slow. Below is (cut-down) sql statement: WITH AllProducts AS ( SELECT p.*, Row_Number() OVER (ORDER BY ProductId)...

Code Review Tools for Transact SQL

I am looking for automated code review tools for transact sql ...

How to connect .NET with sql database?

Hello, I currently have Visual Studio 2005 and SQL Server 2005. I have installed an empty database into SQL Server, but I don't have any idea how to use VS to connect with the database. What kind of project should I use (I'm going to use the database in a windows application) and exactly how will I be able to insert it to the project an...

Is there a quick way to change the keys and foreign keys of my database during the development stage with script

Is there a quick script I can use in SQL Server to change the ID from int to unique identifier without physically going through and doing it manually. I have contemplated code gen to achieve this, but I would have thought using TSQL would be the quickest if possible that is! ...

Bulk insert in SQL Server Express 2005 is not working

I'm having problems bulk inserting data into my SQL Express 2005 DB. I'm using the following code: BULK INSERT [dbEPi].[dbo].[postcode] FROM 'C:\Development\postnummerRegister.txt' WITH ( FIELDTERMINATOR = '\t', ROWTERMINATOR = '\n' ) and I get the following error: Msg 4866, Level 16, State 1, Line 1 The bulk load failed. T...

sql help with getting data

I have a table called Forms with fields ID, FormName and a couple of other fields. I have another table called FormFields which has the FormId as a foreign key as well as an ID and a FieldName and FieldValue fields. The idea is that this should be able to save and retrieve data for generic forms. How can i get all the data from the Fo...

Linq for sql server reporting services, is it possible?

Is it possible to use my existing Linq data model for server side reporting (sql server 2005 reporting services)? ...

SQL UPDATE with JOIN

I need to update table in SQL Server 2005 with data from its 'parent' table, see below: sale --------- id (int) udid (int) assid (int) ud --------- id (int) assid (int) sale.assid contains the correct value and want to update ud.assid with its value. What query will do this? I'm thinking a join but I'm not sure if its possible. ...