sql

SQL Server - Adding a string to a text column (concat equivalent)

How do you add a string to a column in SQL Server? UPDATE [myTable] SET [myText]=' '+[myText] That doesn't work: The data types varchar and text are incompatible in the add operator. You would use concat on MySQL, but how do you do it on SQL Server? ...

How to process a Master Table??

hi, every body, Please advice for the following task in C#.net I am having one master table and one transaction table. The master table consists the following columns..& Data.. Code description amount code 101 abc 150 D (Debit) 102 def 50 C (Credit) 103 hfh 200 D (Debit) ...

StoredProcedure returning multiple resultset Sql To Linq using designer

I want to get multiple resultsets from a storedProc using sql to linq. I was not able to generate it from designer so I wrote below code in designer.cs file. But whenever I add something to designer, it refreshes the designer with the markup in .dbml file and hence it removes the below code every time I add something. I have to copy it e...

LINQ to SQL context.SubmitChanges - How to get error details?

Hi! I'm working on an application where a lot of data is inserted into an SQL database at once. I use LINQ to SQL, and have something like this as my insert operation: foreach (var obj in objects) { context.InsertOnSubmit(obj); } context.SubmitChanges(); Here's the problem: If I get an exception (for instance, DuplicateKeyException),...

An object or column name is missing or empty.

I am getting the following error An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Add a name or single space as the alias name. for the query show below: CREATE PROC [dbo].[Sp_T...

With AS error in SQL

i am getting the error as shown below : Msg 156, Level 15, State 1, Procedure Sp_Table1, Line 22 Incorrect syntax near the keyword 'AS'. while executing this SQL: WITH myCTE AS (Select mci.* from view_name AS si JOIN merch_catalog_ipt_view_name AS mci ON mci.view_id = si.view_id AND mci.resolved_view_name_id = si.view_name_id A...

The multi-part identifier "si.shi" could not be bound.

i am getting the error as shown below : The multi-part identifier "si.shi" could not be bound. while executing this SQL: ;WITH myCTE AS (Select mci.* from view_name AS si JOIN merch_ctlg_ipt_view_name AS mci ON mci.view_id = si.view_id AND mci.resolved_view_name_id = si.view_name_id AND mci.ctg_ipt_event_id = @ctg_ipt_event_id ...

How to have Foreign Key Relation with a field that may contain Multiple Types of it?

Hello I am currently working on a DVD Store App. There are two tables in which I am having an issue. First is the Genres and the other is DVDCatalog. I need that DVD can be listed in one or more Genres. So, to do that I have to store like the IDs of the Genres (4,5,6). This way I can't make a relationship with the GenresID in the Genres...

Can SQL sort on the significant part of a number?

I have a column of country dialcode numbers I want to filter the prefixes into the left most dial code This is the source column: prefix ------ 542 54299 374 37477 37493 37494 37498 37447 37455 3749 37410 297 29756 29759 29766 29769 29796 29799 29773 29774 297600 297622 247 61 61861 61862 61863 This is a example of the result I want....

Tomcat and Ajax Issues

Hello, it's really the first time for me to post. I'am encountering a problem with my Web Apps and cannot find any answers on the web. My problem is that i have a Java Web App that works on parallel with tomcat and apache using mod_jk. Everything works fine, but after one day of running in tomcat, the Ajax request i do with Jquery dos...

Remote permanent synchronization

We have 2 servers, which one of them is customer's. Our customer is providing us an URLs of XML/JSON exports of his clients informations from his CMS and our task is to write some import scripts for importing data to webapp, which we're developing. I've always been doing that like this: INSERT INTO customers (name,address) VALUES ('Joh...

Are there any benefits of using SqlDbType.VarChar instead of SqlDbType.NVarChar if all columns in the database are varchars

All columns that contain text in the database used to be nvarchar but we converted them to varchar for performance reasons. I am now left with all my SqlParameters still using SqlDbType.NVarChar and I want to change them to SqlDbType.VarChar but I don't want to waste time doing it if I won't see any benefits from changing them. Is it wor...

Problem creating SQLite trigger

Hi. I have a table called posts having an INT field posted and a table domains having field posted too, this one is supposed to be the sum of a posteds of posts belonging to a certain domain. Whether the post belongs to a domain is determined by a foreign domain_id in the table posts which links to the id in domains. I'm trying to create...

Lookup table for oracle decodes?

Hi there, It might be a newbie question, but still.. We are all familiar with Oracle's decodes and cases, e.g. select decode (state, 0, 'initial', 1, 'current', 2, 'finnal', state) from states_table Or the same sort of thing using CASE's. Now let's say I have a table with these same values:...

SQL get polls that specified user is winning

Hello all and thanks in advance I have the tables accounts, votes and contests A vote consists of an author ID, a winner ID, and a contest ID, so as to stop people voting twice Id like to show for any given account, how many times theyve won a contest, how many times theyve come second and how many times theyve come third Whats the faste...

SQL Server 2008: No 'release savepoint' for current transaction

Hello, I'm using a PHP database abstraction layer to work with both MySQL and SQL Server. MySQL has a 'release savepoint' statement which SQL Server does not support, and I can't find a comparable statement within T-SQL to use in its stead. Does anybody know of a way around this, or can the lack of functionality be safely ignored? I'd ...

oracle raw datatype in where clause

Hi I have a column of RAW type in my database. How can I use it in where clause? i.e to get only values with third byte equal to 4. this does not work: SELECT v from T where v[3]=4 ...

Wordpress SQL statement help needed?

Hello,I want to select with sql latest post from one category,I know how to select latest post from all category but dont know how to JOIN tables.Can someone help me with this,and explain a little. My sql statement. SELECT id,post_title,post_date FROM wp_posts ORDER BY post_date ASC How to select from one category,I'm trying some code...

TSQL, help with small query about user's age

I have a table with registered users, in which i save year as varchar values simply because i take just an year. I want to create pie chart with ages to show which users are more likely to register. Query below gives me count of user ages which appear more than 5 times in Table to avoid small results. While these small results, below "...

Getting the identity of the row I just inserted

I've got two tables that are linked with foreign keys. I need to do a few inserts on one table and then use the identity column values are part of my next batch of insert statements. This all has to be done through SQL. I've been reading about SCOPE_IDENTITY() but all the examples I'm seeing are using ASP/PHP/Whatever to do the substitu...