Quantcast
Channel: Microsoft SQL Server
Viewing all 4871 articles
Browse latest View live

SQL query to get same day chek in time on different columns.

$
0
0

Hello! I'm having a little trouble getting around to get a report from a sql table where i have all the employees check in and check out times. 

The data looks like this:

Text
ID	CHECKTIME
33	2016-04-01 08:59:08
33	2016-04-01 13:00:22
33	2016-04-01 13:53:52
33	2016-04-01 19:00:51
34	2016-04-04 09:00:00
34	2016-04-04 17:00:00

And what I'm trying to achieve is to get the data like this

Text
ID	DAY		CHECK1		CHECK2		CHECK3		CHECK4
33	2016-04-01	08:59:08	13:00:22	13:53:52	19:00:51
34	2016-04-01	09:00:00	17:00:00

I can't get around how to aggregate the data. I can get Max and Min of every day but i miss the middle.

Thank you very much


SQL Log Growth

$
0
0

I have a sql2014 database that I use Ola Hallengren Index Optimizer that runs every day at 2:45 in the morning to help keep the data properly maintained.  The issue I have is I have a couple of tables that are rather large in this database and when it runs it causes the log file to grow to over 20GB and 125 VLFs and when completed is only used 2%.  The one solution I thought of would be to run DBCC SHRINKFILE on the log as the second step of the SQL Job.  Would this be the best practice or is there some other option I should use.


Pregenerated report which pulls up records multiple times

$
0
0

Hello,

We have one report and which is send us by email every day by SQL jobs.

I just see drop date for one student multiple times.

I donot want Remilard-Kunz Virginia three times same value in drop date column.

How could I get rid of this column.?

I am also attaching code here to get clear idea.

Do you ever get this kind of situation before?

Any help would be appreciated.

Thanks

SSIS Flat File Import to SQL Server - All Files Flowing through Error Path

$
0
0

Hello

I am importing a .csv file to sql via SSIS. All is going ok although the file that we are trying to import is not what I would call "clean". I can't do anything about that as it is from another company. I have therefore created an error table in SQL as well as the table for the import.

Basically all of the files (over 14000) flow into the error table. I have opened the .csv file in Excel and although some of the rows have blanks spaces instead of NULLs, there are some that I thought would have gone through.
looking at the error codes I get the following:

In my data flow there is a fLat file Source with error out put going to ole db destination
The data flow from the flat file source goes to a derived column to add a column with the System Start Date and then on to a ole db destination.

Nothing too fancy I though

ErrorCode -...

transfer data from one id to another

$
0
0



Hello, 

We have one employee with two id's. Now we want to delete one id, but we still need to transfer their data from one id to another to keep records up to date. The id which we want to delete it depends on 26 tables. How could I transfer all data from that table? Is there any way to transfer automatically? Could you please share some ideas with me? Another word, I can say I want to merge two id's data, and then I want to delete another id.   


Setup is unable to connect to SQL Server with connection information.

$
0
0

The only thing I can think of is the names. Because I deleted a previous SCCM Install because we had missed pre-reqs before installing. I went back extended AD and went through all pre-reqs very carefully. I have confirmed that the firewall is disabled, it is not configured to use dynamic ports, firewall is disabled, and I am pretty sure the account used to run setup has permissions to connect to the specified SQL server instance. I am completely stuck here.

SQL Express 2012

$
0
0

I have a awkward situation here SQL Express 2012 is show
ing that the Database size is 8109.00MB in SQL Management Studio but in actuality the MDF file is 5.19GB is SQL counting the LDF file toward the database size?

The LDF file size is 2.72GB  which would explain the 8109.00MB but I though SQL Express doesn't count the LDF file toward the DB Size?

SQL Configuration

$
0
0

I am planning to deploy MS SQL Server 2014 - Standard Version. The current DB Size is about 400GB and plan to grow to about 700-800 GB in the next 3 years

I am looking for some advise on how to configure the disk. My plan is to have SSD drives in the following configuration

RAID-1 for OS Drives

RAID-10 for Data Drives where SQL will be installed.

Is this the best configuration or can I just create a single RAID 10 and install both OS and SQL Server with a Hot Spare.

Would appreciate if you can provide Pros and Cons or Best Practices for our environment.


how to count number of student in existing script

$
0
0

Hello,

I have one script. I need to modify that script. I have different types of courses in that crs_cde column. I need to find number of students under that course. I have tried using group by but it gives me different number of rows than original one. Could you please give me some better idea to deal with this situation. I am also sharing my code here to get clear view.

SELECT section_master.yr_cde,

section_master.trm_cde,

section_schedules.room_cde,

section_schedules.bldg_cde,

section_schedules.loc_cde,

section_schedules.crs_cde,

section_master.short_crs_title_1,

section_schedules.monday_cde,

section_schedules.tuesday_cde,

section_schedules.wednesday_cde,

section_schedules.thursday_cde,

section_schedules.friday_cde,

section_schedules.saturday_cde,

section_schedules.sunday_cde,

...

SSMS Exports to CSV

$
0
0

Hey there, 

I have a query that shows all the data I need, formatted the way I need it when it shows up in the results grid in SQL Server Mgmt Studio.

I created a SSIS package that exports to a csv but the data gets formatted wrong. Commas have not been removed, so it creates problems when I want to use the csv somewhere else. 

i have tried opening the resulting files in NotePad, WordPad, and Excel and the data seems to get screwed up somewhere in the SSIS process.

Is it possible that some of the functions that I use in the query, such as CASE, SUBSTRING, and REPLACE are not being fully processed by the SSIS package, even though the query parsed successfully when I created it?

Thanks for any advice, 

Shawn

SQL cursor :: Search rtf files for string.

$
0
0

I have some Text stored in RTF file outside of a database.    I have a query that will tell me the names of all these files.   Some of hem will have a specific string in them,  some wont.

I am looking for a way to either interact with the  filesystem to determine which files do,  or a way to pull in the RTF file as text, and do a like of find against the imported text.

Can anyone provide me with some insight into this challenge?

Thank you,

Add Linked Server in SQL Server 2012

$
0
0

I have two servers running SQL Server 2012. SERVER A has a named instance, SERVER B has only the default instance.

SERVER A is running SQL Server 11.0.3156

SERVER B is running SQL Server 11.0.5343

Both are on the same subnet. I'm attempting to add SERVER B as a linked server on SERVER A, using the add linked server wizard.

I've tried using both the FQDN and IP address as the linked server ID. Server type is SQL Server. Under security, I have no login mappings defined; all connections should "Be made using this security context:". The username is sa, and password is the sa password.

When I attempt to save the server, I get the error:

Text
TITLE: Microsoft SQL Server Management Studio ------------------------------ The linked server has been created but failed a connection test. Do you want to keep the linked server?...

Executing xp_cmdshell inside of a stored procedure

$
0
0

I am currently migrating from Sql Server 2005 to 2008R2. I have legacy code that calls a custom executable inside of a stored procedure. The procedure with this line compiles in 2005 but not 2008R2:

exec xp_cmdshell 'whoami.exe'

After some research I found that it will compile using this syntax:

exec .master..xp_cmdshell 'whoami.exe'

Please note the period before master. I have not been able to find any documentation on why the period before master is needed. Can someone please explain what the period does and why?

SQL-Server

$
0
0

 Gibt es hier die SQL Spezialisten? Die Auslastung der Zentraleinheit ist 100% vom SQL Prozess. Worauf kommt es an? Wenn ist es die große Anfrage wie kann ich herausbekommen was für Anfrage ist das? Sagt, bitte, ist es möglich die Ressource der Zentraleinheit zu beschränken?

Auto update SQL table entries using foreign keys

$
0
0

Hello,

I am using Microsoft SQL server 2008. I have 2 SQL tables Table 'Product1' and Table 'Product2'. In 'Product1' Table I have columns named

1.SLNO,

2.Name,

3.Place

4.State

And 'Product2' have columns named,

1.SLNO,

2.Name,

3.Place

4.State

5.regno

here SLNO (of product1 table ) =  regno.

My requirement is to update the column in 'Product2' table when I modify data in 'Product1' table ( 'name' 'Place' and 'state' column).

Is it possible to update 'Product2' table without running individual queries for each rows ?

If yes how to do this ?

Please help.


Trying to open ports for SQL/SCCM setup

$
0
0

netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow

The above is the last line of my PS1 script that opens up the firewall ports for sccm and sql to communicate with each other. The last line of my script fails and I am not sure why. The other lines were successful.

I get a specified protocol value is not valid.

Cluster for Windows 2012 R2 and SQL 2014 running on VMWare

$
0
0

Hi all,

I have created a cluster for my new environment that I am setting up to replace the physical servers I am running on my network. I researched it a little, and I also discussed it with VMWare, but I am not sure about the Microsoft part of the equation.

My Environment: EMC SAN Array, Windows 2012 R2, and VMWare 6.x

What I have done so far:

Created the LUNs at the SAN level

Added a small drive for the Quorum on each one of the VMs using an RDM drive with a shared SCSI controller(different from the original 0:0 and physical for sharing).

My cluster is up and running

My Question:

If I am going to run a SQL server on one of these clusters, do I need to have every single disk (other than the OS) on the server being an RDM drive?

Does that mean that all of my databases will have to reside on the RDM disks? (and logs, and backups, etc.)...

MS SQL Backup OnSite server to Azure Blob Storage - Real World Experiences

$
0
0

Hi fellow spiceheads,

I am looking into other options for our off-site backups of our MS SQL (2014) data and I came across this Azure blog post https://azure.microsoft.com/en-gb/documentation/articles/storage-use-storage-sql-server-backup-resto...about using Azure Blob Storage. I had already seenthe SQL Server Managed Backup to Azure and thought it wouldn't be suitable for us as we have a large Archive Set which is rarely modified (6TB approx) plus our live data but after finding SQL Server Backup to URL I'm now thinking this will suit our needs as we can just modify parts of our existing backup regime to go to Azure.

Our current bandwidth is not suitable so before that is improved I had hoped to get your experience of using this?

Is the upload/backup at the full speed of your connection or can it be limited by Azure?

Is it possible...

Error in adding 'ON DELETE CASCADE'

$
0
0

Hello,

I am getting an error while running a query,

I have two tables Parent and Child. In both tables I have columns named Name, Place and State. I know its not a good practice to have that, but for time being I cant change that.

So I have added 'Unique constraint' for 3 columns (Name, Place and State) in parent table using,

Text
 ALTER TABLE parent ADD  UNIQUE(column) 

and created foreign key in Child table using,

ALTER TABLE child ADD

FOREIGN KEY (column) REFERENCES parent(column);


While adding 'ON DELETE CASCADE' to child table I am getting error, that

"There are no primary or candidate keys in the referenced table"

Is it possible to set ''ON DELETE CASCADE" without adding primary key in the parent table ?

Also how to add "ON DELETE CASCADE" for some foreign keys ? In my case I have 3 foreign keys ( Name, Place and State)....

SQL Process - Cannot generate SSPI context

$
0
0

We have recently moved a custom application to a new domain we are moving to for a variety of reasons, adjusting its settings to point to the new servers that it will be using.

If the application is run by the domain administrator, it works without issue. However, when run by the user who actually utilizes it, they get the error "The target principal name is incorrect. Cannot generate SSPI context."

We have confirmed this user has all the necessary rights to work on the file and database. Can anyone provide me with some idea how to resolve this issue so that the user is able to run this application.

Viewing all 4871 articles
Browse latest View live


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