sql-server-2008

update tab1 set col1=col2,col2=col1

How this query swap data of col1 and col2 of tab1 ? Basically for swapping we need temporary variable but here we are not. so how sql server does this ? ...

how use replace in exec statement in sql server 2008

Hi, I have a stored proc, say, "call_Me" with few parameters: Declare @Greet varchar(100) = 'Hi ||User||' Exec Call_Me 1,'something', @Greet --parameters: bit, string, string during the call, I want to be able to replace the ||User|| bit with something else. normally, in a select statement, I would do this: select 1, 'somethin...

SQL Server Equivalent to ORACLE INSTR

Hi All, I wanted to know if in SQL Server there is an equivalent to the Oracle INSTR function? I know that there is CHARINDEX and PATINDEX, but with the oracle version I can also specify the Nth appearance of the character(s) I am looking for. Oracle INSTR: instr( string1, string2 [, start_position [, nth_appearance ] ] ) The CHARINDE...

Free tool to migrate from Sybase SQL Anywhere 12 to MS SQL Server 2008

I need to recover data from a Sybase SQL Anywhere 12 (I have an *.db file) into MS SQL Server 2008. I installed the SQL Anywhere 12 Developer kit and that allowed me to run the database and installed ODBC drivers that should have allowed me to do this. I managed to use the SQL Server Import/Export wizard to import a single table by typ...

basics of SQL Server 2008 backups

We don't have a DBA and I have to do backups. We have only one database that is 3gb (the others are less than 100mb). The 3gb database is write-heavy, and has very important data. I set up daily backups for all the databases but i think that might not be enough. What are transactional log backups? what is my appropriate backup action...

SQL query question

Here is the table "Answers". I need to get count of QuestionNo that are "R", "W", "" for each section for given AcademicYear and TestNo. What is the best SQL query? AcademicYear StudentID TestNo Section QuestionNo Answer 2010-2011 1 1 2 1 R 2010-2011 1 1 2 2 W...

SQL Server 2008 - basic question on shredding XML

Hello - I'm somewhat new to using XML in sql server, and am having a problem getting the syntax right - and for that matter, probably have some basic confusion about referencing XML elements. Anyway, I'll need to shred XML like the below out into columns. Seems simple, but I can't seem to get the nodes right - or for that matter I do...

sql server 2008 database diagrams table name search

Hi all, I have SQL server 2008 enterprise with a database containing up to 100 tables. I generated a database diagram with all of the tables because I want to get an overview of the database. My question is : How can I quickly find the diagram I want, are there any search functions regarding to diagram search ? ...

SQL Server - How do I query a table for matches with keywords from another table?

I have two tables: Job, and JobKeyword. JobKeyword contains three fields: Id, JobId and Keyword, so every Job has its JobKeyword-s. How can I use SQL Server Full Text Search so it will query the Job table, with keywords from the JobKeyword table? This is my current SQL: WITH JobRN AS ( SELECT TOP (@End) searchTable.*, ROW_NUMBER()...

TSql, building indexes before or after data input

Performance question about indexing large amounts of data. I have a large table (~30 million rows), with 4 of the columns indexed to allow for fast searching. Currently I set the indexs (indices?) up, then import my data. This takes roughly 4 hours, depending on the speed of the db server. Would it be quicker/more efficient to import the...

I need to show the monthly inventory data

I have a table some thing like as follows for Inventory details. InventoryTable. InventoryTableID DateCreated quantity ItemName ------------------------------------------------- 1 2010-02-04 12 abc 2 2010-03-10 4 abc 3 2010-03-13 5 xyz 4 201...

Sending mail or SMS after the query has been executed

Hi, Currently I am dealing with a large dataset and some queries are executing several hours. In the meantime I am doing other things. In order to use time efficiently I have been thinking about implementing the logic to send email or SMS message after the query is complete so I can analyze the data. I know how to do it by writing cust...

How to get words from field in SQL Server 2008

I need to get the words in a text field and make some updates with those words, for example: original data words | other field | another field --------------------------------------------- white | | some words | | some other w | | desired result words | other...

T-SQL cursor and update

I use a cursor to iterate through quite a big table. For each row I check if value from one column exists in other. If the value exists, I would like to increase value column in that other table. If not, I would like to insert there new row with value set to 1. I check "if exists" by: IF (SELECT COUNT(*) FROM otherTabe WHERE... > 1) ...

Pass Value from one DataSet to another DataSet to filter row in Reporting Services 2008

I have 2 table stacked at a single page,one for filtering previous year and 2nd table for the current year and i pass in the same value from the DataSet to these two table , the only difference is that i need to filter it with the year using the Tablix Properties. Right now i am filtering the Year with the hardcoded value like 2008,2009 ...

Inconsistent cursor results when looping over databases

I have several databases named very similar (my-db-1, my-db-2, my-db-3, my-db-4). I want to execute the same stored procedure on each of these databases. I decided to use cursors. However, I am getting some strange issues. First here is my simple code that I am executing through SQL Server Management Studio 2008. DECLARE @db_cursor CUR...

SQL query to calculate value from two tables

Hi I have two tables which are related in the following way : Table1 gene goterms ape 1a ape 1b ape 1c boy 2a boy 1a cat 1a cat 1c Table2 gene gene count ape ape 3 ape boy 1 ape cat 2 boy ape 1 boy boy 2 boy cat 1 cat ape 2 cat boy 1 cat cat 2 now,i need value that corresponds to second row ...

Can somebody share the code for connection pooling for sql server in Tomcat 6.x?

Hi, I'm using struts 2 in my application and want to use connection pool to connect to the database. And the database we are using is Sql Server. Pl somebody give all thedetails related to this. ...

Recommend a good .NET 4.0/SQL Server 2008 web host (shared platform)

Hi all, This is my first question so play nice!!! I've done a search and could only find similar questions relating to .NET 3.5 last year so I thought I'd ask for people's recommendations at this point in time regarding a good web host to use for a small e-commerce website that will run on .NET 4.0 with a SQL Server 2008 back end. Opi...

Upload Picture to a SQL Server database using MVC

Hi guys, I was looking to upload an image (jpg) to a SQL Server database using MVC. Basically - my user would be able to navigate to a page, Browse their computer using a file upload textbox/browse button, and click submit to have the file uploaded to the database. Fairly new to MVC and not quite sure how to go about this. There's ...