sql-server

Sanitize search string for Dynamic SQL Queries

I know i can use stored procedures to eliminate sql injection attacks but it would bloat the code by more than I'm willing to accept and making it costly to maintain. In my dynamic sql query, I would like to search a string of text in 2 columns in one of my tables but before that happens, I would like my business layer, which is written...

Migrating asp.net web site breaks Membership Provider

I have a asp.net web site that was developed on the .Net Framework v2 connecting to sql server 2000. I am trying to migrate it to a new server that has the .Net Framework v3.5 on it along with sql server 2008. I backed up the database and restored it to the new database server. I moved the web site and updated the web.config. Now however...

Better to use Stored Procedures or SQL in my code for working with data?

When it comes to CRUD operations and your database (SQL Server '08), is it better to write the SQL statements into your code or use stored procedures? Why? As pointed out below, I omitted LINQ as a third option. This was done because I am not familiar with LINQ. . . yet. If LINQ is a better option, please let me know what I'm missing. ...

TSQL subset supported in Windows Azure Data Services?

Windows Azure Data Services supports a subset of TSQL. What are the features of SQL 2008 not supported? ...

tsql- set options

I am rebuilding indexes using a script which reorganises or rebuilds indexes according to a predefined fill factor. It is on SQl 2000. I have the following SET options in my script: SET ANSI_WARNINGS OFF SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON I am getting the following error: DBCC failed because the following SET options have i...

SQL Query including time calculation

Hi, Had a good search here but can't see anything that gets my mind in gear for this one. Basically I have a table call Diaries, this contains fields such as StartTime EndTime, I need to do a calculation that works out the difference in minutes between StartTime and EndTime. then for each row that fits that day I need to add up the res...

Impact on NHibernate caching for searches with results including calculated value mapped as a formula (e.g. rank)

When defining a calculated property using a formula in NHibernate, what are the implications for when the formula varies its result depending on the query restrictions, especially with regards to query caching? More specifically, consider the following simple C# class: public class Entity { public Entity() { } public virtual in...

Can MS SQL Server 2000 handle Chinese text encoded with Unicode?

Hi all, Now, I am using Ms sql server 2000 and I want to store my data as the unicode for chinese font. But I don't know it can store this type or not? If not, could anybody guide me? Thanks, Sopolin ...

Is there an advantage on setting tinyint fields when I know that the value will not exceed 255?

Should I choose the smallest datatype possible, or if I am storing the value 1 for example, it doesn't matter what is the col datatype and the value will occupy the same memory size? The question is also, cuz I will always have to convert it and play around in the application. UPDATE I think that varchar(1) and varchar(50) is the sa...

how to compare server time

work on Sql server 2000. i want to get the current server date and time then want to compare it with my table column EntryDate .How to? Declare @id datetime Select @id = DATEPART(hour,GETDATE()) SELECT [Name],[BirthDate],[Email] FROM Customers3 where BirthDate<=@id-1 AND BirthDate>=@id want to get on the range value like @id=10.I wa...

Allow special characters SQL Server 2008

I am using SQL Server 2008 express edition and its collation settings are set to default.I wish to store special characeters like á ,â ,ã ,å ,ā ,ă ,ą ,ǻ in my database but it converts them into normal characters like 'a'. How can I stop SQL Server from doing so? ...

SQL Server datetime LIKE select ?

in MySQL select * from record where register_date like '2009-10-10%' What is the syntax in SQL Server? Thank you. ...

unable to start sql 2005 on windows 2003 two node cluster

SQL server Agent is not starting...... In the SQLAGENT log i found this error....... 2009-10-24 22:49:36 - ? [393] Waiting for SQL Server to recover databases... 2009-10-24 22:49:40 - ! [298] SQLServer Error: 5845, Address Windowing Extensions (AWE) requires the 'lock pages in memory' privilege which is not currently present in the ac...

SSIS: How to delete rows from a resultset before using the OLE DB Destination?

Hello! I have a problem using the SSIS. I try to import data from database one to database two. Therefore I use a OLE DB Source with the following command: SELECT Name, Description, JobID FROM DBone.Table My problem is, that I only want to import new data from this source. So I use a second OLE DB Source withe the following command...

How do I convert a nested select to joins when nested select has a temp table?

I have the following SQL. Tables defined. #tbContinent -------- ContinentID | ContinentName AddressInCountry -------- AddressID | CountryID AddressInContinent -------- AddressID | ContinentID NameInAddress -------- AddressID | NameID I then have the following SQL: --- Insert into tbName DECLARE @tbName TABLE ([ID] int, [Add...

SQL Server: Serial number generator implementation question

Hi folks: My clients need a format of serial #: YYYYMMDD098 where YYYYMMDD represents today, 098 is a 3-digit number that will get increased by 1 every time we access the serial #. Furthermore, the 3-digit # will trun back to zero every day. Where can I find a reference for this solution? Thanks. ...

SQL : BETWEEN vs <= and >=

In SQL server (2000 & 2005 ) What is the difference between these two queries ? Which one I should opt on which scenarios ? Query1: Select EventId,EventName from EventMaster where EventDate BETWEEN '10/15/2009' and '10/18/2009' Query2: Select EventId,EventName from EventMaster where EventDate >='10/15/2009' and EventDate <='10/18/...

If Record Exists, Update Else Insert

Hi there, I'm trying to move some data between two SQL Server 2008 tables. If the record exists in Table2 with the email from Table1 then update that record with the data from Table1, else insert a new record. In Table1 I have a number of columns; firstname, surname, email and so on. I'm not quite sure how to structure the query to up...

How to connect to other system Database?

Using VB6 and SQL Server 2005 I want to write a sql connection for connecting to other system sql server. Code ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI; Persist Security Info=False;Initial Catalog=STAR;Data Source=" & SName & "" In SName - Am giving a Server Name The Above connection code is working for the...

how do I remove nested select statement

Hi. I have a Name table with the columns NameID Name TypeID With the following SQL SELECT[NameID] FROM[Name] WHERE[TypeID] = @TypeID AND NameID >= (SELECT MIN([NameID]) FROM [Name] WHERE [Name]='Billy' AND [TypeID]=@TypeID) Ive been asked to convert this to an Inner Join without using any nested select but n...