1
SQL Query
Install of Database Engine Tuning Advisor
Hi,
All databases on this site are 2008R2, however I have SSMS 2012 on my desktop.
I would like to install "Database Engine Tuning Advisor" on my PC, would I install the 2008R2 or 2012 versions of this product?
MSDTC
I have installed sql server 2012 on windows 2012 cluster(Active/passive) also I have installed MSDTC.
Our application guy complaining that he can't connect to the cluster, i have checked my windows log saying msdtc could'nt connect, so i have deleted MSDTC from failover cluster manager .
Is there any possibility to bring back MSDTC back to my roles, i haven't deleted the storage and network name of the msdtc
Please help me
Thanks
Copy values between tables and save id
Hello everyone, I am bumping into a problem that is possible easy to solve, but since I am a noob in SQL server, I might be glitching somewhere.
I have a table that holds Image type called Attachments {id, external_id, file_data} which file_data is an Image type. This table file_data must be transfered to a table called UploadedData {id, description, file_data} and hold the generated ID in the attachments
in a field called upload_id.
So far so good:
IF NOT EXISTS(SELECT NULL from syscolumns where name = 'upload_id' AND id = object_id('attachments')) BEGIN ALTER TABLE attachments ADD upload_id INT NULL; ALTER TABLE attachments ADD CONSTRAINT fk_attachments_upload_id FOREIGN KEY (upload_id) REFERENCES uploaded_data(id); END GO
That is the code to add the upload_id in the attachments table, it worked. Now I have to run through all attachments and create a new record for each attachment in the uploaded_data and save this generated id in the attachment field upload_id. This is where i am glitching.
To be precise, I dont know how to do it, i tried creating a temporary table and inserting values there, but I dont know how to intermediate it between both. Any help, documentation, etc would be very appreciated.
With kindly regards
André
sorting tables
What different ways could you sort a list of data into a specific order, i.e.:Smallest to largest? Cheapest and most expensive by group?
sukai
Cannot copy mdf files.
Hi,
I am not sure if it is a right forum for the question. I tried to copy a file from "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\aaa.mdf" to a
place. But a message pop out
Cannot copy aaa: It is being used by another person or program. Close any programs that might be using the file and try again.
I restarted the machine but still got it. Nobody use the file except me.
Why? Thanks.
Creating a new database using an MDF file
How to find User Login Password in SQL Server?
Hi All,
Earlier one of my team member has created a user login and password but forgot the password after few days and now we need to know the password of that login. Some of the application are using this login so we can delete and create a new login with the same name hence is there any possibility or script to find out the password of the existing login.
Note: The login is not 'sa'
Please let us know if any additional information is required.
Really grateful to your interest, time & suggestions on this.
Regards,
Kalyan
----Learners Curiosity Never Ends----
How to Avoid Redundant Indexes on Indexed Views
Syntax question - columns noted in parentheses?
I found this query somewhere on the web, copied it to my notebook but part of it I never understood - why the two columns in parentheses? What does that accomplish?
select x.employeeid, y.thecount
from humanresources.employee x
join
(
select p.managerid, count(*)
from humanresources.employee p
group by p.managerid
) y (managerid, thecount) on y.managerid = x.managerid -
How to email result of a select from SQL
Hi All,
Our application does not have notification feature when certain customers missed their payments. Is it possible to schedule a job in SQL server to send an email to the account manager when ever customers miss their payments. I can write a select statement to get the list of customers who missed their payment but need help to send the results to the respective account manager.
Regards,
Jaggy
How to write procedure or SQL select query
Hello All
I want to make procedure or select query where same PID(Permanent ID) admitted to the hospital at different date. If the date difference(day) is equal 7 days then 1 and it will search next date(RegDate). If previous DisDate and current RegDate difference(day) is greater 7 days then 2 else difference current RegDate and DisDate. My table structure as given below.
PID NVARCHAR(11)
RegDate DATETIME
DisDateDATETIME
NameNVARCHAR(50)
Sex INT
Help me as you can
How to script all sql jobs
Hello,
Is there a way in sql2k5 to script all sql jobs at once. In sql2k you could right click on the agent and select that option however I do not see it in sql2k5. Thanks.
Index job failed with this error Msg 1222, Lock request time out period exceeded. [SQLSTATE 42000]
HI All,
I am using Ola index optimization for rebuild\reorganise indexes and update stats. but it is failing continuously with this error.
Msg 1222, Lock request time out period exceeded. [SQLSTATE 42000].
2 days back i have stopped the whole environment and i were run these jobs manually that time job was successfully run. after that again job failed.
our database size is 3.5 TB. we are using sql server 2008 R2 with sp2.
complete error message
DateTime: 2014-11-17 05:37:28 Command: ALTER INDEX [R_ROY_MEMBER_U7_X] ON [mydb].[dbo].[R_ROY_MEMBER] REBUILD WITH (SORT_IN_TEMPDB = OFF, ONLINE = ON) Comment: ObjectType: Table, IndexType: NonClustered, LOB: No, AllowPageLocks: Yes, PageCount:
10359, Fragmentation: 76.1367 [SQLSTATE 01000]
Msg 50000, Sev 16, State 1, Line 109 : Msg 1222, Lock request time out period exceeded. [SQLSTATE 42000]
please suggest me on this issue.
/Raghavendra
System database Backups
Login failed for user
I have a SharePoint server which is using service account "spsharepoint".
For some reason this user has started giving 'Login failed for user spsharepoint' when I checked SQL Server logs. Turns out it is trying to access 'master' database on which it doesn't have access so the error.
I gave read only access to this user on master database but error is still coming. What could be the issue and how do I fix this?
How to merge 3 different query results using full outer join?
Hi all This is my my query for 2 results
with t1 as (
select trans.crAcc_id,trans.cr_amt,row_number() over (order by trans.head_id) rn from Acttrans trans,
Acttranhead head where trans.head_id in(select link_id from acttrans where head_id=12) and trans.crAcc_id!=0
and head.head_id=trans.head_id
),
t2 as (
select trans.drAcc_id,trans.dr_amt,head.[Vouc_No],head.[Vouc_Date] ,head.[Check_No],head.[Check_Date],head.[stat],row_number() over (order by trans.head_id) rn from Acttrans trans,
Acttranhead head where trans.head_id=12 and trans.drAcc_id!=0
and head.head_id=trans.head_id
)
select t1.crAcc_id, t1.cr_amt,t2.[Vouc_No],t2.[Vouc_Date] ,t2.[Check_No],t2.[Check_Date],t2.[stat],t2.drAcc_id,t2.dr_amt from t1
full outer join t2 on t1.rn = t2.rn
Query 3: SELECT [CrAcc_Id] FROM [KSSDATA].[dbo].[ActTrans] where head_id=12 and crAcc_id!=0
and i want to add Query3 result to the ABOVE RESULT but i am unable add third result using full outer join
Thanks
Balu D
does non clustered index contain clustered index
hi all,
i want to create a non clustered-index(say cover index) for the below query
Question : does non clustered index contain clustered index, please let me know which index would be the best
CREATE TABLE [tab1]( [col1] [int] NOT NULL, [col2] [int] NOT NULL, [col3] [int] NOT NULL, [col4] [int] NOT NULL, CONSTRAINT [PK_tab1_col1] PRIMARY KEY CLUSTERED ([col1] ASC) ) GO select col1,col2,col3 from [tab1] where [col1]=@col1 and [col2]= @col2 and [col3]= @col3 --index 1 create index idx_ncl_perf1 on [tab1](col1,col2,col3) --index 2 create index idx_ncl_perf2 on [tab1](col2,col3)
Thanks