sql-server-2005

SQL Server: How can I SELECT FROM TABLE TO Other Format

I have Table A. How can I select from Table A to get Table B Format. Table A Employee Name Effective Date FieldType FieldValue Maung Mya 1/1/2005 Title Project Engineer Maung Mya 1/1/2005 Department IT Department Maung Mya 1/1/2007 Title Assist Project Manager ...

Bulk Insert takes 4x as long on first operation of the day

I do Bulk Inserts into a table with about 14 million rows at fiver minute increments during a 7 hour period during the day. These inserts take somewhere between 9-14 secs. However, the first insert always takes about 40 secs. Anyone know what SQL Server 2005 would be doing differently on the first insert into a table for that day? Fr...

MDX Filter a dimention with another dimension

To all excuse my ignorance, but im new to MDX below is the query im trying to run SELECT NON EMPTY { [Measures].[Task Burn Down] } ON COLUMNS, NON EMPTY { ([Calendar].[Date].[Date].ALLMEMBERS * [Priority].[Priority Code].[Priority Code].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELE...

sql server ports 445 and 1433

What is the differnet between those sql server ports 445 and 1433 and for what every port intended ? ...

Clone DB table row through MVC in SQL Server

Is there a simple solution for duplicating table rows in SQL Server as well as all table rows with foreign keys pointing to the cloned table row? I've got a "master" table and a bunch of "child" tables which have a foreign key into the ID of the master table. I need to not only create a perfect copy of the master table, but clone each an...

Creating a User Defined function in Stored Procedure in SQL 2005

Hello, I have a stored procedure in which i want to create a user defined function - Split (splits a string separated with delimiters and returns the strings in a table), make use of the function and finally drop the function. My question is that whether i can create a user defined function inside a stored procedure and drop it finally...

User define function with in stored procedure

hi, can we create user define function with in stored procedure then end of the store procedure we need to delete that custom user define function. ...

Row concat from this query

I have this query: SELECT DISTINCT IM.EDIFICIOS_ID, TI.TITULAR FROM IMPORTACION IM INNER JOIN I_EDIFICIO IE ON IM.IMPORTACION_ID=IE.IMPORTACION_ID INNER JOIN I_EDIFICIO_TITULAR ET ON IM.IMPORTACION_ID=ET.IMPORTACION_ID AND IE.EDIFICIO_ID=ET.EDIFICIO_ID INNER JOIN I_TITULAR TI ON IM.IMPORTACION_ID=TI.IMPORTACION_ID AND ET.TITULAR_ID=TI.T...

Getting the sum of a datediff result

Hi I have a SQL statement (MS SQL Server 2005) that does a simple calculation of the differences in dates on a few records. I want to return the total/sum of the DATEDIFFs too. SELECT (DATEDIFF(day, StartDate, EndDate)+1) AS myTotal FROM myTable WHERE (Reason = '77000005471247') How do I get the SUM from myTotal? Tha...

How can I efficiently manipulate 500k records in SQL Server 2005?

I am getting a large text file of updated information from a customer that contains updates for 500,000 users. However, as I am processing this file, I often am running into SQL Server timeout errors. Here's the process I follow in my VB application that processes the data (in general): Delete all records from temporary table (to remo...

How to migrate large amounts of data from old database to new

I need to move a huge amount of data from a couple tables in an old database to a couple different tables in a new database. The databases are SQL Server 2005 and are on the same box and sql server instance. I was told that if I try to do it all in one shot that the transaction log would fill up. Is there a way to disable the transaction...

How to get parameter values for dm_exec_sql_text

I'm running the following statement to see what queries are executing in sql server: select * from sys.dm_exec_requests r cross apply sys.dm_exec_sql_text(r.sql_handle) where r.database_id = DB_ID('<dbname>') The sql text that comes back is parameterized: (@Parm0 int) select * from foo where foo_id = @Parm0 Is there any way to get ...

Importing a SQL Server 2005 Profile Trace Template into SQL 2008

I'm using SQL Server 2008, but my ERP Vendor only offers a SQL 2005 trace template that they'd like me to run on my system. When I attempt to import it, I receive confirmation that it was successfully imported. However, it does not show up in the list of available templates. I've done this on two separate servers to the same effect. ...

Importing NULL Values in Tab-Delimited File Using SSMS 2005

I'm in the process of importing a very large tab-delimited text file using the Import Wizard in SQL Server Management Studio 2005. Some of the column values are empty, which are represented by the string value "NULL." However, when I try to import the file I get the following error message dialog: Is there some other value I should ...

SQL Server: String Manipulation, Unpivoting

I have a column called body, which contains body content for our CMS. The data looks like: ...{cloak:id=1.1.1}...{cloak}...{cloak:id=1.1.2}...{cloak}...{cloak:id=1.1.3}...{cloak}... A moderately tweaked for readability example: ## h5. A formal process for approving and testing all external network connections and changes to the f...

What's an efficient way to convert month and year string to a date?

I have column with varchar values like "022008" that I need to convert into a datetime like "02/01/2008". This will run on millions of records for a conversion process. What is an efficient select statement for doing this? ...

How to bulk insert from CSV when some fields have new line character?

I have a CSV dump from another DB that looks like this (id, name, notes): 1001,John Smith,15 Main Street 1002,Jane Smith,"2010 Rockliffe Dr. Pleasantville, IL USA" 1003,Bill Karr,2820 West Ave. The last field may contain carriage returns and commas, in which case it is surrounded by double quotes. And I need to preserve...

how to take a backup from server database ?

I have connected to local and server database from local SqlServer 2005. How to take a backup from server database ? Regards, kumar ...

Find earliest and latest dates of specified records from a table using SQL

Hi I have a table (in MS SQL 2005) with a selection of dates. I want to be able to apply a WHERE statement to return a group of them and then return which date is the earliest from one column and which one is the latest from another column. Here is an example table: ID StartDate EndDate Person 1 01/03/2010 03/03/2010 Paul 2 12/05...

T-SQL: Using OVER and PARTITION BY

Hello, I have the following data | Item | Value | Date | ------------------------------ | 1 | 10 | 01.01.2010 | 1 | 20 | 02.01.2010 | 1 | 30 | 03.01.2010 | 1 | 40 | 04.01.2010 | 1 | 50 | 05.01.2010 | 1 | 80 | 10.01.2010 | 2 | 30 | 04.01.2010 | 2 | 60 | 06...