sql-server

Which data type in c# is better suited for currency calculations?

And also the better counter part in sql server for mapping. ...

Populate large data from database.

I have develop 3-tier application and I have issue about populate data from database. My application has some window that query large data from database and this process take a very long time. (My client is so far from server and connection between it is 128 KBS) Then I have think for the solution to solving this problem. The solution is...

Perform INSERT with SELECT to insert multiple records.

In the diagram below there is a 1:1 relationship between 'DodgyOldTable' and 'MainTable'. Table 'Option' contains records with 'OptionVal1', 'OptionVal2' and 'OptionVal3' in the 'OptionDesc' field. I need to do an insert into MainTable_Option with a select from DodgyOldTable. Something like this: INSERT MainTable_Option ([MainTableID],[...

Report Server aggregation over groups by line

Maybe this is a newbie question, but Imagine I have a report that shows the sales-order list pr sales-rep, itemized to sku level, and want to show how many percent of the total sale of 1 sku, the sales-rep has sold. I.e. Sales-person List of orders - List of items no sold: 5 out of this months total 942...

How do I add a record to a database with LINQ?

I have been utilizing Scott Gu's tutorials on LINQ to SQL to try to learn some LINQ. I have been able to view, retrieve, and update records but I am unable to write new records into the database (MSSQL). Scott starts getting into inserting rows in the fourth section of the set of tutorials. As you can see on that page (or may already kn...

C# Assembly Injection Check

I'm creating an assembly in C# for MS SQL 2005. This assembly creates a stored procedure and runs a dynamic query based on parameters passed into the stored procedure. Is there a simple function in C# to prevent SQL injection? For example string myQuery = "SELECT * FROM dbo.MyTable WHERE lastName = '" + injectionCheck(arg1) + "'"; T...

Programmatically detect SQL Server Edition

I'm using C# with SMO and attempting to detect what edition of SQL Server (e.g., enterprise, standard) I'm connecting to. I know how to get the version information, but that only tells me what version of SQL Server (e.g., SQL Server 2008 vs SQL Server 2005). Does anyone know how to get the actual product edition (e.g., enterprise, stan...

Migrating MOSS 2007 from SQL 2000 to SQL 2005 - Addendum

This is a continuation of an earlier question I had about moving the databases for a MOSS 2007 installation from SQL 2000 to SQL 2005. Here's the URL for the original question: http://stackoverflow.com/questions/254517/migrating-moss-2007-from-sql-2000-to-sql-2005 In my test environment, I've successfully moved the databases to the SQ...

replication

How can we find out that if a replication job or normal replication is running at a particular time. Please,help to figure out. Thanks ...

How to create an SQL Server 2008 database from script

I'm trying to do an Entity Framework walkthrough so I: downloaded SQL script here: http://www.learnentityframework.com in SQL Server Management Studio, I right-clicked Database, Create Database, named it right-clicked on the new database, New Query clicked on "Open File" and opened the script file: Create_ProgrammingEFDB1_SQLServer2008...

"infinite" sql statement?

Hi there, I've got a very strange sql-related problem. I'm accessing a MSSQL Server 2005 with PHP (odbc), when I profile the sql statement the following is executed: declare @p1 int set @p1=180150003 declare @p3 int set @p3=2 declare @p4 int set @p4=1 declare @p5 int set @p5=-1 exec sp_cursoropen @p1 output,N'SELECT fieldA, fieldB,...

SQL Server Maintenance Suggestions?

I run an online photography community and it seems that the site draws to a crawl on database access, sometimes hitting timeouts. I consider myself to be fairly compentent writing SQL queries and designing tables, but am by no means a DBA... hence the problem. Some background: My site and SQL server are running on a remote host. I u...

What tool do you use for developing and administrating your database?

I have always used TOAD by Quest to do my development and administration work in Oracle and MS SQL Server. However, I am trying not to be myopic in my choices. Are there other tools that you would recommend that will allow me to connect to the database(s) and perform my development and administrative duties? ...

Choosing a Platform C#/MsSql or Php/Mysql or JSP or what?

Hi all, It seems like there are an inordinate number of really intelligent people here, so I thought it was the best place to ask a couple involved questions (shameless flattery). Your feedback on any item would be so appreciated. I am about to develop a very large web based operations, inventory, sales management system. I had inten...

Copy table to a different database on a different SQL Server.

I would like to copy a table from one database to another. I know you can easily do the following if the databases are on the same SQL Server. SELECT * INTO NewTable FROM existingdb.dbo.existingtable; Is there any easy way to do this if the databases are on two different SQL Server's, without having to loop through every record in the ...

Problems with CLR Code on Sql Server 2005

I am considering accessing some CLR code from a UDF in Sql Server 2005. I've heard stories that unhandled exceptions thrown in CLR code can bring down the server. Obviously my function would contain a try-catch block. However, certain exceptions (stackoverflow) can skip the catch. Does anyone have a set of guidelines that can comp...

How to browse results with php mssql ?

I'm working with php and I want to do a next button that's step to the next 10 records (like when you browse question with stackoverflow) I don't know how to do that but I'm thinking to do it with Top n record ? Do you think that's a good idea ? Any suggestion? ...

Audit each inserted row in a Trigger

I am trying to do an audit history by adding triggers to my tables and inserting rows intto my Audit table. I have a stored procedure that makes doing the inserts a bit easier because it saves code; I don't have to write out the entire insert statement, but I instead execute the stored procedure with a few parameters of the columns I wan...

How to implement LIMIT with Microsoft SQL Server?

I have this query with mysql : select * from table1 LIMIT 10,20 How can I do this with Microsoft sql ? ...

MSSQL Assemblies and SQLBinary DataType

I have a c# assembly which takes in a SQLBinary variable to decrypt... [SqlProcedure(Name="Decrypt")] public static SqlInt32 Decrypt(SqlBinary toDecrypt) { return runQuery(toDecrypt); } // decrypt or encrypt is determined based on the datatype of argValue private static SqlInt32 runQuery(object argValue) { // create connection ...