Quantcast
Channel: Transact-SQL forum
Browsing all 23857 articles
Browse latest View live

Security context issue when executing a SQL command in SQLCMD

Simplified core issue below: I have myscript.sql that has:SELECT name FROM Sys.Databases GO USE mydatabase GO EXEC mystoredprocedure 'myparameter' GOWhen I open cmd.exe and use:SQLCMD -S...

View Article


STATISTICS IO: Scan Count vs Logical reads

HelloI'm doing som performance research, I have a index with following priority: ClientId, Active, ProductId. Active is a bit field telling whether the Product is active or not, it can be inactive...

View Article


Building table for graph data in SQL 2012

I am on Windows 7 x64 with SQL 2012.  I am new to SQL server and need some guidance.  I have raw data I would like to store.  The raw data is Amplitude vs. Time.  there are 3600 rows 2 columns.  What...

View Article

Linking two table..it is look like unpivot but it is not

Hi guys, I got a situation like this:Table A create table #fly (company varchar (50), period varchar(6), adcost (int), ppcost (int))insert into #fly values ('PanAm', '201401', 100, 200) ,  ('PanAm',...

View Article

Subquery returned more than 1 value. This is not permitted when the subquery...

Hi i am trying to fetch the data in three tables by using their version colums.HERE IS MY CODE:INSERT INTO [dbo].tblCALPLA(ACCOUNT,DATASRC,VERSION)SELECT ACCOUNT,DATASRC,VERSION FROM [dbo].TBLFACTWHERE...

View Article


How Can I Bulk Insert data like this 0.0096 & 0.0088 & 0.0055

I've tried FLOAT and NUMERIC(18,4).  Every time, all my numbers are stripped out, and all I get is NULL.I'm using this:CREATE TABLE:Weight    numeric(18,4)CREATE STAGING TABLE:Weight...

View Article

Converting column to row dynamic

hi friends,just wondering if some one can help me writing this query?drop table #tempcreate table #temp (branch varchar(20), branch_no varchar(5), client varchar(100))insert into #tempselect 'LA',...

View Article

Nested transactions in internal SP - RollBack

Hi,I have internal SP as follows:   CREATE PROCEDURE [dbo].[Internal_SP]   @lngID int AS  beginset nocount OFF;insert into dbo.Table_Test_1 (id, txt)select @lngID, 'Internal SP 1';end;The main SP which...

View Article


REPLACE street type abbreviations to full value

hello, I am trying to build a query that will go through an address column in my table and locate street type abbreviations and replace them with the full value for example 123 Main St I want to show...

View Article


IF STATEMENT WITH A CASE STATEMENT WITHIN A SQL SELECT

    SELECT CASE STATUS WHEN 'WO' THEN ISNULL(REPLACE(TempWOID, '~', '') , '')  ELSE CAST(INVOICE AS NVARCHAR(20)) END AS INVOICE,A.CUSTOMER, CAST(A.CUSTOMER AS NVARCHAR(50)) AS CUSTOMERSTRING, C.NAME,...

View Article

Why the more powerful server writes data slower than the less powerful server ?

We are using SQL Server 2012. The same database myDB (Simple Recovery mode, Autogrowth by 1000 MB on the data, and by 100 MB on the Log) exists in 2 different servers, server A and B. Server A...

View Article

Image may be NSFW.
Clik here to view.

You can be our next Spring T-SQL Guru !!

In the northern hemisphere at least, Spring is here! (apparently)And at TechNet Wiki, we're hoping you're all hatching new ideas for this month's TechNet Guru competition!We're looking for more shoots...

View Article

Image may be NSFW.
Clik here to view.

Complex Insert Into; Some Data in One Table is Pivoted

I have a table like this:INSERTINTO dbo.GI_CL(Date,Index_Code,Price_Return_Level,Gross_Total_Return,Description) I have another table called: [dbo].[SPGT_Daily] I want to do something like the...

View Article


Date wise Stock

Hi Everyone this is the original database table  Item_NO Posting_date EntryType LocationCode Quantity I0013078 12-2-2013 4 RW003 -1 I0013078 12-2-2013 4 INTRNASIT 1 I0013077 12-2-2013 4 RW003 -1...

View Article

"SELECT * INTO table FROM" a stored procedure? Possible?

I did a search and read a few solutions but they just don't make too much sense to me. Forgive my newbie-ness but I'm still pretty new when it comes to stored procedures. I'm still learning every...

View Article


merge statment error 102

An error message occurred when I run the following code Merge dbo.individual AS a -- target using (Select id, fname, lname from [dbo].[Staging_table]) AS b -- source on a.id=b.id --when matched then...

View Article

How to get hardware related metrics of SQL Server through query ?

Hi Folks,               I am newbie to the SQL Server programming. I also follow this forum only now. I am not sure if these kind of question had been asked in the past. Let me furnish you more detail...

View Article


Last & First SQL aggregate functions

I'm trying to migrate an app. from Access to SQL Server, and find that Transact-SQL does not support LAST/FIRST functions.  Is there any alternative to these?Below is the Access SQL statement:SELECT...

View Article

Database opens as read only

I have installed the application of mine to the my computer and the other computer that are running on Windows 7 64 bit and all of the function are worked fine (adding the data to the database through...

View Article

Merge Statement

Environment: win7, SQL Server 2008 R2Application: Microsoft SQL Management  Studio 2008 R2, Business Intelligence 2008 - SSISCode:CREATETABLE Staging_Table ( id CHAR(9),ssn CHAR(9)NOTNULL,Fname...

View Article
Browsing all 23857 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>