sql-server

sql server query - is writing multiple queries the only way?

If I have a table of fruits: FruitId ColorId NumofPurchased. I want to return a row for each of the colorId's where NumOfPurchased is max for that colorId. I am coming up with approaches like looping through the colorId's or manually write 10 queries for 10 colors ... I don't know, is there a better/more optimized way to do this? I ...

which is faster views or stored procedure? asp.net sql server

Hi Everybody, i want to know whether views or stored procedures are faster. i am developing application in asp.net with sql server. Which one should i use for good performance of asp.net application. Thanks ...

[.NET] Storing an encrypted password into a database

I thought this would've been a lot simpler but at this point I'm confused and haven't progressed at all. Basically, I need to be able to accept a password from a user in a WPF app, encrypt it then store this in a database and be able to decrypt later on. However I'm not sure how to implement this. This is completely trivial so whether...

SQL Backing up with SMO & C# ?

I'm using the following code to back up a SQL Database : void BackupDatabase(string sConnect, string dbName, string backUpPath) { using (SqlConnection cnn = new SqlConnection(sConnect)) { cnn.Open(); dbName = cnn.Database.ToString(); ServerConnection sc = new ServerConnection(cnn); Server sv = ne...

Using Backup Database Programatically

Hello everyone, I was just wondering, how can I use a .bak database backup file (Backed up via query in SQL Server) programatically? I want my application to back up my database to a location (which I can already do) and I also want it to be able to load a backed up database (the .bak file). Can anyone help me with this using C#? Tha...

SQL Server 2000 vs. 2005+ sample databases to study db design?

I always tried to learn using the most recent versions of SQL Server, books, articles, docs. I started to doubt whether it is efficient. I've got a feeling that I am frequently inefficiently loosing time with learning materials based on bloated AdventureWorksXXX sample databases from SQL Server 2005+. Even simplest principles and conc...

how to skip from a row in script component

How to skip some records in script component without using conditional split component? ...

How to use SQLConnect or SQLDriverConnect

Hello, I am trying to connect to a MS-SQL server on the internet. What should I put on the ServerName parameter of SQLConnect? I've tried this, but it fails: "DRIVER=SQL Server;SERVER=SERVER_IP;DATABASE=sales" SERVER_IP is something like 111.111.111.111,9999 EDIT: I followed Johns advice and here is my current code: SQLCHAR OutCon...

How can I search for strings with characters not on the keyboard (non-english)?

I have a search form that I want my users to be able to enter English character equivalents for non-English characters. For example. To find Ælfred, the user could search for "Ælfred" or "AElfred". the search should also be case insensitive so "aelfred" would work. I also have it searching so that, by default, it matches the beginning o...

How to get Ruby on Rails to generate a model using sql server 2008

Ruby version: 3.0.2 Rails: 1.9.2 OS: windows 7 DB: sql server 2008 (r2) I tried to execute the following command: rails generate model product The error I get can be seen here: pastebin.ca/1965168 I tried to follow these two sites: rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html www.lostechies....

How should I migrate this data into these Sql Server tables?

Hi folks, I wish to migrate some data from a single table into these new THREE tables. Here's my destination schema: Notice that I need to insert into the first Location table .. grab the SCOPE_IDENTITY() .. then insert the rows into the Boundary and Country tables. The SCOPE_IDENTITY() is killing me :( meaning, I can only see a w...

column to row in sql server ?

Table: CREATE TABLE Table1 ( col1 INT, col2 nvarchar(10), col3 INT, col4 INT ); INSERT INTO Table1 (col1, col2, col3, col4) VALUES (1, 'welcome', 3, 4); My table have different data type , col2 is nvarchar h can i do this ... result: col value --------------- col1 1 col2 welcome col3 3 col4 4 ...

vb6 run time error 13

i am using sql server for database. In my coding when am inserting integer value into table am getting type mismatch error. my code as set rst1=cnn1.execute("select distinct(tagid) from pgevent") it returns some values when am trying to insert into another table am getting error cnn1.execute("insert into tags values("+cint(rst1.field...

SQL Server: can a stored proc that updates tables be called from within a CLR UDF

I don't know why, but CLR User Defined Functions are not allowed to update tables. Is it possible to work around this restriction by calling a stored procedure from the CLR UDF that updates tables for it ? ...

Replace function in a query

@"SELECT [MN].[PK_ID], [MN].[FK_NOTEADDED_BY], [MN].[ADDED_ON], REPLACE(MN.NOTE_CONTENT, '\n', '<br/>') AS [NOTE_CONTENT], ...

How to use the library Data Mining Web Content Viewer

Hi all! I am developing a web application that will work with Data Mining-models deployed to Analysis Services. I downloaded the library Data Mining Web Content Viewer of Microsoft SQL Server 2008 R2 Feature Pack (http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ceb4346f-657f-4d28-83f5-aae0c5c83d52&amp;displaylang=en). Instal...

Problem select specific column name using sql statement

I found problem when trying to retrieve specific name column that using syntax/statement/command using sql. Example I have table 'dcparam' with name some column 'SELECT', 'INSERT', 'UPDATE' in database sqlserver. Then I trying to select using query: SELECT SELECT,INSERT,UPDATE FROM dcparam Well it could be solve using "*" in select, ...

Select Query is not working with WHERE clasue when there is a space in Column Name

I have got SQL Server database in which Table column name have spaces. For example I have a Table something like this: ID| First Name| Last Name|Birth Date 1 | Wasim | Akram | 01-01-2000 2 | Saeed | Anwer | 01-01-2001 Now When I use a following query(column name with space) I get empty result: SELECT * FROM table WHERE...

VB6: How do I connect to SQL server without the service manager installed on the client?

I am creating an application in Visual Basic 6.0 which has SQL server as its database. I want to connect to the database without having MS SQL service manger installed on the client. How can this be done? Should i add any dll's or .tbl or .ocx files? ...

Problem with generated SQL from Hibernate (MS SQLServer)

Hi, I have a problem with Hibernate generating an SQL that do not work on SQLServer (works on PostgreSQL without any problems). I have tried to set the hibernate dialect for SQLServer but the same SQL is still generated and still do not work. The HQL query looks like this: select count(t) from ValidationLog t The generated SQL looks ...