sql-server

Query in SQL2000

How to alter the datatype of a column in a table? ...

Setting Up TFS Server outside of a domain

Hi Im trying to set up TFS 2010 on a machine that is connected to a network, but not on the domain. I am trying to connect this to a SQL Server that is also connected to the network and also not on the domain. When I run through the TFS configuration Wizard and try to connect to the SQL Server, it fails with a message "A connection can ...

TSQL Query: Escaping Special Characters

Hello all, I am trying to escape special characters in a TSQL query. I have done this before: SELECT columns FROM table WHERE column LIKE '%\%%' ESCAPE '\' And it has worked. Now I have tried to do this now: UPDATE match SET rule_name='31' ESCAPE '\' But it has failed. I know none of the vlaues have a \ but it should still work. I...

Query in SQL2000

How to drop a Particular column in a Table? Thanks in Advance ...

Getting all rows from a Table where the column contains only 0

I got a little problem i need a sql query that gives all rows back that only contains 0 in it. the column is defined as varchar2(6) the values in the column looks like this: Row Value 1 0 2 00 3 00 4 100 5 bc00 6 000000 7 00000 my first solution would be like this: Oracle: subst...

The entity framework and database agnostic programming, possibilities?

We want to use the Entity Framework (.NET 4.0) to build applications that can deal with Sql Server, MySQL and Oracle. And maybe Sqlite too. It should be easy to switch the db vendor by some setting in a config file. Is this possible? I prefer real life examples! What kind of providers did you use? ...

Is file_get_contents multi line?

Hello all, Does file_get_contents maintain line breaks? I thought it did but I have tried this: if($conn){ $tsql = file_get_contents('scripts/CreateTables/SLR05_MATCH_CREATETABLES.sql'); $row = sqlsrv_query($conn, $tsql); print_r(sqlsrv_errors()); } The errors I get is that SQL Server complains that there is incorrect...

Sql Server - How to calculate the size of some rows from each table in a database?

How can i calculate the size of only some rows for each table? For example, with the code: EXEC sp_spaceused 'myTable' you obtain the size of all rows, however i want to calculate the size not of one single table, but all of them, and using the same clause for each one, something like this in pseudo-code: foreach(Table myTable in Da...

LINQ to SQL: Get records from two DB's that are on different servers.

I need to fetch records from tables, that are in two diff. databases in two different SQL Servers. For Instance. Sales DB on server1 and Purchase DB on server2. Both Sales and Purchase DB's have some set of tables say table1 in Sales DB and table2 in Purchase DB. Now, I need to get records from table1 and table2 that are having some co...

Anyway to get a value similar to @@ROWCOUNT when TOP is used?

If I have a SQL statement such as: SELECT TOP 5 * FROM Person WHERE Name LIKE 'Sm%' ORDER BY ID DESC PRINT @@ROWCOUNT -- shows '5' Is there anyway to get a value like @@ROWCOUNT that is the actual count of all of the rows that match the query without re-issuing the query again sans the TOP 5? The actual problem is a much more com...

Most concise way to convert Julian date (yyyy[day of year]) to SQL datetime

I'm working with an existing database where all dates are stored as integers in the following format: yyyy[3 digit day of year]. For example: 2010-01-01 == 2010001 2010-12-31 == 2010365 I'm using the following SQL to convert to a datetime: DATEADD(d, CAST(SUBSTRING( CAST(NEW_BIZ_OBS_DATE AS VARCHAR), 5, LEN(NEW_BIZ...

Constant Push of SQL Server data to MySQL

Is there a way I can have a constant update of my SQL Server data going to a MySQL database? ...

Why should I use SQL Server's BETWEEN ... AND syntax?

These two statements are logically equivalent: select * from Table where someColumn between 1 and 100 select * from Table where someColumn >= 1 and someColumn <= 100 Is there a potential performance benefit to one versus the other? ...

Excel > Microsoft Query > SQL Server > Multiple Parameters

Hi, Im relatively new to sql server and excel/microsoft query, I have a query like this Select ...[data]...B1.b,B2.b,B3.b From TABLEA Inner join ( SELECT ---[data]...sum(...) as b From TABLEB WHERE Date between [startdate] and [enddate] ) as B1 Inner join ( SELECT ---[data]...sum(...) as b From TABLEB WHERE Date between [startdat...

In SQL Server changing column varchar(255) nvarchar

Hi, I am using SQL server 2008 express and some of our columns are defined as varchar(255). Should I convert these columns to NvarChar(255) or nvarchar(max)? The reason I ask is I read that nvarchar(255) for unicode characters would actually store 1/2 the number of characters (since unicode characters are 2 bytes) whereas 255 with varc...

IIS 7 - floats returning with commas instead of periods

I'm having trouble reading rows with float values, because these rows return for example 12,34 instead of 12.34 as it should. I suspect this is because both my IIS and SQL server is on a Norwegian Windows Server 2008. So I went to the regional settings and customized the default decimal symbol, then restarted my servers. The output in ...

Finding gaps (missing records) in database records using SQL

I have a table with records for every consecutive hour. Each hour has some value. I want a T-SQL query to retrieve the missing records (missing hours, the gaps). So for the DDL below, I should get a record for missing hour 04/01/2010 02:00 AM (assuming date range is between the first and last record). Using SQL Server 2005. Prefer a set ...

String to DateTime in C# to save in SQL server

Hello All: I have an issue while converting "March 16-17" to DateTime and saving it to SQL server. "March 16-17" as it looks, read as March 16 to March 17, which in my case is invalid, but C# DateTime.TryParse() is treating "March 16 -17" as March 16, 2017 which is wrong, and saving the data in SQL server. SQL server treats "March 16-17...

how to restore very large .bak file (180 GB) in SQL Server 2008

Hello! I have a verly large .bak file (180 GB) which was stored in Microsoft SQL Server 2008 and I have to restore it. I first installed Microsoft SQL Server 2008 Express and tried to restore it in MS SQL management studio express but it didn't work because there is a size limit. Does anybody know a method how i can restore the file? It...

Can you insert the results of a dynamic sql call into a SQL Server 2005 table variable

Is there anyway to do this in SQL Server 2005? declare @tv_tablelist table (recnum int identity(1,1) primary key, newvar varchar(500)) declare @mysql nvarchar(4000) set @mysql = 'insert into @tv_tablelist(newvar) values (''test test test'')' Exec sp_executesql @mysql, N'@tv_tablelist table (recnum int identi...