sql-server

Display view content in SQL Server2008

How can I display the content of all Views in a db in SQL Server 2008? Is there any new system views to do the same? ...

Can we write subquery in between SELECT and FROM

i want to know, how to write subquery in between SELECT and FROM as SELECT Col_Name,(Subquery) From Table_Name Where Some_condition ...

WCF with MANY database connections

I'm working in the development of an ERP type .Net WinForms application consuming a WCF service. It's to be used by many small companies (in the range of 100-200). Database is SQL Server 2008 and the service will be hosted as a Windows service. Even thought there will be a single DB Server, our customer insists in having separate datab...

Hierarchy based aggregation

I have a hierarchy table in SQL Server 2005 which contains employees -> managers -> department -> location -> state. Sample table for hierarchy table: ID Name ParentID Type 1 PA NULL 0 (group) 2 Pittsburgh 1 1 (subgroup) 3 Accounts 2 1 4 Alex 3 ...

[SQL server 2K] What is the impact coming from wildcard %

Hi guys: I need to add a new SELECT statement whose search condition include something like leagueCode LIKE 'nba%'. I would like to know if the index against leagueCode is still exploitable or introduce any overhead after % is included in the target column. ...

Sample Employee SQL Server database with data

Hi I need some sample SQL Server Employee database with data such as id, surname, name, age, adress etc. It must be quite big, I search with google, but I don't find any good sample. Can any body help ? ...

How to insert artificial data into a select statement

Hi guys: Suppose we got a original query as follows: SELECT A, B, C FROM tblA Now, I need to additional artificial rows like SELECT 'Kyala', B, C FROM tblA when, for example, C = 100 to be inserted into the resultset. As an example, if the tblA hold one row: A B C John 1 100 my goal is to return two rows like b...

[SQL server 2K] Bookmark Lookup

Hi folks: I see a node named "Bookmark Lookup" in my execution plan. What does it means? It costs most among steps inside the plan. Any suggestion to optimize it? ...

Best Ruby ORM for Wrapping around Legacy SQL Server Database?

Hi. I found this answer and it sounds like almost exactly what I'm doing. I have heard mixed answers about whether or not datamapper can support SQL Server through dataobjects. Basically, we have an app that uses a consistently structured database, consistently named tables, etc in SQL Server. We're making all kinds of tools and stuff th...

Pivot Tables In Sql Server With Spaces In Cell

My example is similar to this - The only problem is I cannot rewrite this query to cope with columns that have spaces inside it In the example below suppose that rather then [Oranges] you had ['Oranges And Apples'] in one cell. For some reason adding an "'" means the pivot function returns NULL everywhere and [Oranges And Apples] is of...

forcing Management Studio to use alter table instead of drop/recreate

Hi! I'm wondering if is there a way to force MSSQL Management Studio to produce a script like this: ALTER TABLE Mytable ADD MyCol bit NOT NULL CONSTRAINT MyColDefault DEFAULT 0 WITH VALUES ALTER TABLE [dbo].Mytable ALTER COLUMN MyCol2 int NULL GO when I alter a very simple property of a column on a table. If I do this in the desig...

Copy huge tables data from one database to another in SQL Server.

I have two database say DB_A and DB_B. In DB_A database, table having huge data (few tables are having 2 to 10 million data). I want to move the all table data from DB_A to DB_B database. Please help me on writing stored procedures to move efficiently (fast) the data from one database to another. ...

[SQL Server 2k] The relationship between join sequence and index setting

Hi folks: I heard that setting index is closely related to the sequence of joining tables. Could you provide some examples or article about this point? Thanks. ...

Display part of entry

Suppose a query "select streetAdr from Address" returns "236 a1 road" "333 a2 road" and 444 a4 road" as 3 rows. How i can display only "236" "333" and "444" in SQL Server. ...

Editing a 9gb .sql file

Hi. I've got a "slightly" large sql script saved as a textfile. It totals in at 8.92gb, so it's a bit of a beast. I've got to do some search and replaces in this file(specifically, change all NOT NULL to NULL, so all fields are nullable) and then execute the darned thing. Does anyone have any suggestions for a text editor that would be ...

How can I query the database culture (SQL Server 2005) ?

How can I query the database culture (SQL Server 2005) ? I have problems inserting and getting dates, because the client's servers don't run on the same culture as my developer server. I can adjust the date, but I need to know the server's culture... ...

T-SQL UPDATE trigger help

Hi iam trying to make an update trigger in my database. But i get this error every time the triggers trigs. Error MEssage: The row value(s) updated or deleted either do not make the row unique or they alter multiple rows(3rows) and heres my trigger ALTER TRIGGER [dbo].[x1pk_qp_update] ON [dbo].[x1pk] FOR UPDATE AS BEGIN TRY DE...

SQL Server 2008 full-text search doesn't find word in words?

In the database I have a field with a .mht file. I want to use FTS to search in this document. I got this working, but I'm not satisfied with the result. For example (sorry it's in dutch, but I think you get my point) I will use 2 words: zieken and ziekenhuis. As you can see, the phrase 'zieken' is in the word 'ziekenhuis'. When I searc...

SQL Server: How to get a subitem of sp_helplanguage ?

Question: I can get the SQL Server database language by querying: SELECT @@language And I can get further info via EXEC sp_helplanguage How can I query for a column of sp_helplanguage where name= @@language I do SELECT * FROM sp_helplanguage WHERE name='DEUTSCH' but that obviously doesn't work. What's the correct way to query i...

SQL Server: how to set return format ?

Question: The new SQL Server 2008 database returns me values formatted English (date/float). Is there a way I can set the return format ? For example temporarely switching the database language? Or just set the language for the current query ? ...