Tag: sql-server-2008-r2

How can I search all columns in a table?

How can I search all columns of a table in SQL Server?

Efficient query to split a delimited column into a separate table

I have some data that includes a column with delimited data. There are multiple records in the same column essentially: A0434168.A2367943.A18456972.A0135374.A0080362.A0084546.A0100991.A0064071.A0100858 The values are of variable length, and delimited by periods. I’ve been attempting to create a lookup table for this data, using a cursor. Due to the volume of data, the cursor is unreasonably […]

How to concatenate all columns in a select with SQL Server

I need my select to have a pattern like this: SELECT ‘<text> ‘ + tbl.* + ‘ </text>’ FROM table tbl; The ideal solution would have all the columns separated by a comma in order to have that output: SQL result for Table 1 with two columns: ‘<text>col1, col2</text>’ SQL result for Table 2 with […]

replace NULL values with latest non-NULL value in resultset series (SQL Server 2008 R2)

for SQL Server 2008 R2 I have a resultset that looks like this (note [price] is numeric, NULL below represents a NULL value, the result set is ordered by product_id and timestamp) product timestamp price ——- —————- —– 5678 2008-01-01 12:00 12.34 5678 2008-01-01 12:01 NULL 5678 2008-01-01 12:02 NULL 5678 2008-01-01 12:03 23.45 5678 […]

Exit single-user mode

Currently, my database is in Single User mode. When I try to expand me database, I get an error: The database ‘my_db’ is not accessible.(ObjectExplorer) Also, when I try to delete the database, I get the error: Changes to the state or options of database ‘my_db’ cannot be made at this time. The database is […]

Find a specific column entry in an unknown table in a database?

I’m aware of this topic ( Find a specific column in an unknown table in a database? ) and my problem is quite similar. The query I need is quite similar to this one (I think): SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE column_name LIKE ‘%watcher%’ But what I need is a query […]

SQL Server 2008 R2 to MySQL Migration

Is there a GUI tool out there that will allow me to migrate entire SQL Server 2008 R2 databases to MySQL? I have MySQL Workbench installed, but it looks like there isn’t a feature in it like SSIS to copy and paste entire databases from SQL Server. I downloaded the MySQL Migration Toolkit, but it […]

How to remove white space characters from a string in SQL Server

I’m trying to remove white spaces from a string in SQL but LTRIM and RTRIM functions don’t seem to work? Column: [ProductAlternateKey] [nvarchar](25) COLLATE Latin1_General_CS_AS NULL Query: select REPLACE(ProductAlternateKey, ‘ ‘, ‘@’), LEN(ProductAlternateKey), LTRIM(RTRIM(ProductAlternateKey)) AS LRTrim, LEN(LTRIM(RTRIM(ProductAlternateKey))) AS LRLen, ASCII(RIGHT(ProductAlternateKey, 1)) AS ASCIIR, ASCII(LEFT(ProductAlternateKey, 1)) AS ASCIIL, ProductAlternateKey from DimProducts where ProductAlternateKey like ‘46783815%’ Result: […]

how to check if table exist and if it doesn't exist create table in sql server 2008

I am writing a Stored procedure in sql server 2008 I need to check if a table exist in the DB, if it doesn’t then I need to create it. How do I do it?

Return total records from SQL Server when using ROW_NUMBER

I would like to return the total number of records in the database so I can set up pagination. How do I return the total number of records in the DB when using the following paging method in SQL Server 2008? ALTER PROCEDURE [dbo].[Nop_LoadAllOptimized] ( @PageSize int = 20, @PageNumber int = 1, @WarehouseCombinationID int […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.