sql-server

How to declare local variables in postgresql?

There is an almost identical, but not really answered question here. I am migrating an application from MS SQL Server to PostgreSQL. In many places in code I use local variables so I would like to go for the change that requires less work, so could you please tell me which is the best way to translate the following code? -- MS SQL Synt...

Stored procedure return varchar

Hi! I am trying to create stored procedure that gone return varchar value, and that value I need to display in textbox. This is the code for stored procedure: Create PROCEDURE Status @id_doc int, @Name varchar(50) OUTPUT AS select @Name =items.name from Doc,Items where @id_doc=IDN and doc.IDN=Items.ID return @Name This is the...

Develop .NET application for free?

Possible Duplicate: Are Microsoft Express editions free to develop on? Is there software available that allows a developer to write .NET applications with SQL Server for free, meaning without buying Visual Studio and SQL Server. As long as you buy Windows web hosting (w/ support for .NET and SQL Server), is there software too...

Entity Framework: How to update database when modifying Model

Hi In Entity Framework 4 there are the options "Update Model from Database" and "Generate Database from Model". But what I'm missing is an option like Update Database from Model which reflects the changes made in the model (e.g. adding a new Property or Navigation-Property) by modifying the database schema (e.g. adding a n...

SQL Server 2008 R2 Geography column?

Hi, I'm using SQL Server 2008 R2 and I can't seem to be able to use the geography column type it's meant to have. It doesn't show up in the data type column when I create a new column and when I run this code: CREATE TABLE [Core].[Address2]( [Geo_Id] [geography] NULL); I get Column, parameter, or variable #2: Cannot find data type...

String manipulation SQL

I have a row of strings that are in the following format: 'Order was assigned to lastname,firsname' I need to cut this string down into just the last and first name but it is always a different name for each record. The 'Order was assigned to' part is always the same....... Thanks I am using SQL Server. It is multiple records with d...

Accessing SQL Server over a network from a Windows Service

I have created a class that will connect to SQL Server to run a stored procedure. When this class is used in a Windows Forms solution, the database can be accessed successfully. When the class is put into a Windows Service, I get the following error: A network-related or instance-specific error occurred while establishing a co...

INSERT INTO results_table EXEC sproc from within a scheduled job

I'm trying to setup a scheduled job that with one step that would insert the results from a sproc into a table. INSERT INTO results_table EXEC sproc The job executes and reports a success. Yet nothing gets inserted into a table. When I execute the same script from the SSMS the results are inserted. What might cause the problem? ** E...

SQL query to avoid duplicates and order by a row

Need a SQL query using joins I need a help Table name: RVW_TSK RVW_ID UPC_CD CMPL_DATE 00001  10101010  10-10-2009 00002  10101010  13-10-2009 00003  20202020  5-11-2008 00004  20202020  8-11-2008 Expected result is like: RVW_ID UPC_CD CMPL_DATE 00002 10101010 13-10-2009 00004 20202020 8-11-2008 I want the lates...

Natural sort for SQL Server?

I have a column that is typically only numbers (sometimes it's letters, but that's not important). How can I make it natural sort? Currently sorts like this: {1,10,11,12,2,3,4,5,6,7,8,9} I want it to sort like this: {1,2,3,4,5,6,7,8,9,10,11,12} ...

Which SQL command can I use to see the structure of a table on SQL Server?

Hi there, I have a table on a SQL Server and I would like to export its structure to send to a colleague. Which SQL command should I issue to get the structure? I don't have access to the SQL Server Management Studio. Thanks ...

easiest way to map ids during database refactoring

i have a number of tables with a column called OrderId. I have just done a refactoring and i want to get rid of the Order table and i have a new table called Transaction. I want all tables that have an OrderId column to now have a TransactionId column This is complete. I now need to populate the transactionId column. I have a mappi...

is count(indexed column) faster than count(*) ?

Possible Duplicate: Performance of COUNT SQL function Hi all, I've very large tables and I need to know number of records in each , My question is does it reduce the run time if I run : select count(indexed column like my PK) from tbTest instead of select count(*) from tbTest ...

Problem using Hibernate and SQL Server 2008

I'm having problems using Hibernate and SQL Server 2008. When I try to save an object to database Hibernate throws this: could not retrieve snapshot: com.my.MyClass Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name `'emanagement.patient_visit'.` The user has select, insert,update privileges in database. ...

Token-based server access validation failed with an infrastructure error

I would appreciate help with the following issue: I have created a local group in our SQL 2008 server and added two Windows user accounts "DOMAIN\UserName" I then added the local group to the database and granted read only access. The users are trying to link tables using MS Access using and ODBC connection and getting the following ...

Can I pass multiple rows from a stored procedure query into another query?

In my previous question I asked about storing the result of a query in a variable... now I realize the query can return multiple rows. I currently have this: SELECT @UserId = UserId FROM aspnet_Users WHERE UserName = @username And I want to do something like this: DELETE FROM some_table WHERE UserId IN ( *the ID list* ) DELETE FROM ...

Oracle vs SQL Server for a .NET project

I know that Oracle is a generally good database engine but I think it is too difficult in deployment for a .NET projects comparing with native Microsoft SQL server solutions. (I needed to install both x32- and x64-bit client components and configure TNS names for both of them, plus install Distributed Transactions support for Oracle. No...

SQL Search column for each variable in CSV string

I have a variable passed to stored procedure Ex: @keywords = 'val1, val3, val5' And i'm trying to see if column named Title contain any of them in it Ex: Title1 - 'Hello val1' Title2 - 'Hello val3' Title3 - 'Hello val1, val3' Title4 - 'Hello' SO my results should return values Title ------ Hello val1 Hello val3 ...

Rails, Redmine, Mysql and SQL Server encoding problems

We had redmine working with mysql (and mysql works fine with utf8). Now we needed to migrate the database to SQL Server (latin1 is the default for us). The data acentuation is ok in SQL Server after the migration, but in the browser, data coming from the database is showing ? in the acentuation place. What could be the solution to show c...

SQL Max parameters

I read here that the maximum number of parameters that can be passed to a Stored Procedure is 2100. I am just curious what kind of system would require a SP with 2100 parameters to be passed, and couldn't one split that into multiple SPs? I thought that maybe an SP that calls multiple SPs would require a lot of params to be passed, I ...