Rewriting 2000 Stored procedure in SQL Server 2008 R2 using Merge
Hello , I'm trying to convert a SQL 2000 stored procedure which Inserts/ updates a target table based on a few conditions , Merge is an obvious choice but have a few issues , there is no similar logic...
View ArticleUsing Credentials with OPENROWSET
I am trying to use an OPENROWSET to access an excel file that is located on a shared drive in order to import the data. I cannot place the file on the SQL Server Machine, so I need to access using the...
View ArticleHow to find the unmatched records between the two tables?
We have to tables in SQL Server database. But unable to find the unmatched record betwwen these two tables. There 12 records are unmatched. But unable to get those records. I am using the below sql:...
View Articletotal row count get from table two different child table to one master table
Create table #tmp_master (mst_id int ) Create table #tmp_child_one (mst_id int,fname nvarchar(10) ) Create table #tmp_child_two (mst_id int,name nvarchar(10) )insert into #tmp_master select 1 union all...
View ArticleSQL Code to Load a Temp Table to Replace xp_cmd_shell
Our area is eliminating xp cmd shell as an option.In what can the following be done without using xpcmdshell.CREATE TABLE #temp(s varchar(2000)) SELECT @cmd_checkfile = 'dir /B "' +...
View ArticleString or binary data would be truncated.
I have stored procedure When I execute them with 20000 char in input that work fine (in stored procedure I declare variable nvarchar(max) ) But when I execute under another procedure with the same...
View ArticleSelect latest month inventory
Hi,I am trying to select inventory value for the last month for each material. The following is the result set from my query and I want to select only the circled rows (inventory value from latest...
View ArticleOptimize a correlated subquery
I have a test subquery here. You can just run it as is in SSMS. I am trying to get a LAST payment date and a and a LAST payment amount and I think I am getting it. The problem is that the way it is...
View Articleproblem in Urdu/Arabic data insert in sql server 2005
hii have trouble to save Urdu/Arabic text in sql table columns when I insert Urdu/Arabic data in sql server 2005 the urdu/Arabic charactor shows as ??? ???????" question mark in the columns. how to...
View Articlehow to find where index can be made
Hi,I have pk and fk in the database , i want to find out where i can make some good indexes.(sqlserver 2005)Questions1) Is there any dmv which can help me in finding out where should i make indexs?2)...
View ArticleUnable to shrink tempdb
Hi All,This is to bring to your notice that when iam trying to see free space using shrink database it is showing 180GB free space.But when i am trying to shrink individual data files they are only...
View ArticleMerge columns
Hi,I have to compare data from 2 tables on 2 different servers with different formats.USE [TestDB] GO /****** Object: Table [dbo].[Table_4] Script Date: 11/20/2013 18:03:47 ******/ SET ANSI_NULLS ON GO...
View Articleexecution order - group by and order by
is there any execution order when we use group by and order by together in single query ?
View ArticleNo lock for updates?
Hi All,We are creating a web application for our end users who are going to enter some data using the UI. Since more than one user is going to be connecting to the application at a time, we are...
View Articleelegant way of carving edit errors off a query resultset
Hi we run enterprise 2012. I thought this would be the best forum to start with.I have a prototype query that selects data from today's "untyped" (almost everthing is nvarchar) stage table and inserts...
View ArticleSQL: System locks up and runs slow after performing simple DML record insert
SQL Version: 2008 R2I am having a serious problem. I ran the following code to perform a simple table record insert which ran successfully. However, after running this code I could no longer access...
View ArticleSQL: INSERT INTO statement not working
SQL Version: 2008 R2I'm trying to run this code, but it never completes and I have to manually terminate it. The same thing happens is I only run the SELECT statement portion (without including the...
View ArticleThe transaction log for database 'mydatabase' is full. To find out why space...
Every time I get this error, at different points of testing inserts and deletions on my table:The transaction log for database 'mydatabase' is full. To find out why space in the log cannot be reused,...
View ArticleFailOver Clustering
Experts,We have a fail over clustering High Availability in place. All our instances are 2008R2. We want to install 2012 on all of the nodes in the cluster and create another fail over cluster group on...
View ArticleAny one can tell me please learning Projects?
Dear All,I have read lots of books on SQL Server and Visual Studio c#. but still I am unable to work in Visual Studio using c# and SQL server 2012. Any one can tell me any book OR any site where I can...
View Article