Newest 'sql-server' Questions

Q&A for professional and enthusiast programmers

create a stored procedure for column (contains comma separated string) in a table

Here is the simple table which I want pass table name and column name as parameters to stored procedure .. Here is the table content CREATE TABLE [dbo].[test]( [ID] [int] IDENTITY(1,1) NOT NULL, ...

Find difference between datetime and time in SQL

I have a datetime variable 2017-03-10 13:05:00.000 and a time variable 12:00:00.0000000 I need to find the difference between the datetime and the time on the datetime's date so I get 1 hour and 5 ...

How to create temp table using Create statement in SQL Server?

How to create a temp table similarly to creating a normal table? Example: CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype, .... );

How to dynamically import Excel data into SQL Server 2008 using C#?

I tried to dynamically import data from Excel sheets into a SQL Server database. I want make permission to user to select which table in the database he want to add in This is my code and I don't ...

In SSMS, anyway to save a variable in memory and use without highlighting?

Is it possible to create a variable in SSMS and then be able to use it without highlighting it? For example, I can run the following two statements together and it works fine: DECLARE @myVariable ...

HTTP Error 500 when trying to execucute INSERT INTO sql query

I'm fairly new to php and SQL and just can't figure out the problem. Note that this is a school project, therefore the vulnerability to SQL Injections and saving the blank passwords are nothing to ...

How to generate a dataset dynamically with a parameter in “from” clause of “select”

select * from (select 0 as hour union select 2 union select 4 union select 6 union select 8 union select 10 union select 12 union select 14 union select 16 union select 18 union select 20 union ...

Sql match id's with names from a table that matches with another table

I have a table friend which has two columns with Id's that belong to specific usernames. See example: Id_Gebruiker is the user and Id_Gebruiker2 is the friend of the user. The table friend has id's ...

SQL Server does not exist or access denied while importing data from Excel into SQL Server [duplicate]

I tried to import Excel file dynamically depending on user's choice. I want give permission to user to select which table in the database he want to add in this. This is my code when I select the ...

save informations in a data base and getting the id sql server c#

It's my first time working with SQL Server and I can't find a helpful tutorial. I am trying to get information from the UI (infos about a contact) and save it to the database (localdb in Visual Studio)...

SQL Server : trigger update column of table after other table insert or update a record

I have 2 tables, ShareButton and SharePage. ShareButton table: +----+---------------+---------------+ | ID | Name | TotalShare | +----+---------------+---------------+ | 1 | Facebook ...

How to copy and replace N' ' to N''

i want bulk copy of sql data to other DB. but problem is here that when i am trying to execute this insert statement. GO INSERT [dbo].[HaveWantMaster] ([HaveWantMasterID], [Type], ...

How to retrieve data which is not present in any field of one table in SQL Server?

I want to retrieve a data which is not present in any field from Table1 For example I have two table 1. #tempLastSold 2. ItemRelation #tempLastSold records ID ExtendedDescription StoreID ...

How to find maximum date by joining table in my scenario in SQL Server?

I have 2 tables. 1.#tempUnsold 2.ItemDynamic These are the records from #tempUnsold table ID ChildId1 ChildId2 ChildId3 ------------------------------------ 111 112 113 114 ...

How to restore SQL server database from external drive without uploading database to local hard disk?

I am running win7 on a VM. I have Microsoft SQL Server 2014 downloaded on the VM. I have an external drive with a .bak file that I wish to restore a database with. The database is 400+ GBs. My local ...

SQL - Joining fact and dimension data within Date ranges

I have 2 tables in my sql server database that i would like to join based on their dates range. This data is confidential, i will try to keep this as clear as possible although i got to uncover the ...

Not able to execute a stored procedure from C# in Web API, but I am able to execute from SQL Server - is there any mistake in my code?

This is my code try { var Result = string.Empty; DbCommand command = db.Database.Connection.CreateCommand(); command.CommandText = "Sp_InsertSetmodelparameters"; command.Parameters....

SQL performance issues, need help optimizing this query if possible

I am not a SQL expert and need some input. I have the query below which takes over 2 hours to run and consequently times out. Company policy is we cannot alter the timeout period of a SQL query to be ...

SELECT funcionario.name WHERE COUNT() > AVG() GROUP BY funcionario

I wont to SELECT funcionario.name WHERE COUNT() > AVG() GROUP BY funcionario funcionario = Employee cliente = client SELECT funcionario.nome FROM cliente INNER JOIN funcionario ON cliente....

ASP.Net - SQL Query Allows “SELECT” Command Only at Application Layer [on hold]

The situation is that the user can specify the SQL without restriction, but I cannot setup an account in database with limited right (allows "SELECT" only). Is there any method to filter all other SQL ...

How to format a Date into SQL server using EntityFramework

I'm trying to storage into my database ONLY the DATE not DATE AND TIME, only Date, but it always came with the time together. This is how I do to storage only the date inside of String : string....

Is it a bad practice to use a single column table with a nominal value as PK?

When dealing with No-SQL databases, this would not be a problem as a relation would not make sense (or at least would be unnecessary), but when the infrastructure does not support No-SQL databases, ...

how to show data of four table in one crystal report using vb.net

I am working on a society project. I am using sql database and vb.net. I have four tables on the database as follows. Registration Nominee MemberDetail MachineryDetail I want to show data from all ...

Switching from SQL to postgres in Django [on hold]

I am switching from SQL to postgres in django will this lead to a data loss in my existing database

BROKEN? ASP.Net Core Identity User login being based on UserName DB field and not NormalizedEmail

Recently I noticed with my WebAPI I am creating based on generic template for 'Individual Account' setup, that upon trying to re-log a registered user back in even though the login page/view requestes ...

Why do I see “Blank” or “0” value at the begging of Stacked Column Chart in Power BI Desktop

For some reason stacked column chart displays "Blank" value even though data behind doesn't have any Blank or '0'. And my X-axis doesnt have "Type" where I can choose between continuous or ...

Cannot restore SQL Server 2008R2 database

I took a backup of the database on a disk from a server that I do not have online access to. Trying to restore the database on my local machine using: RESTORE DATABASE MYDB FROM DISK = 'C:\Program ...

Getting XML node value and all nested column nodes

I have here a small extract of the XML files I will have to handle: <garRoot fileMaster="9371034.0582.30582"> <garTransactions> <garTransaction InnerTransId="89274503"> &...

How sqoop converts sql datatypes into hive

I need complete list of SQL Server datatypes converted to hive in sqoop. Like SQL Server's timestamp is converted to hive string, SQL Server varchar is converted to hive string, etc. Where can I ...

How to use NOT EXISTS in SQL Server in my case?

I want to retrieve some data from one table which is not present in another table. #tempLastSold table records (actual records 3000) ItemID ------ 9 41 43 45 65 68 79 5773 5834 5838 ItemRelation ...

SQL Update only duplicate row

table_paysched id | ilno | acctno 1 | 1 | 001 2 | 1 | 001 3 | 2 | 001 4 | 1 | 002 5 | 1 | 002 6 | 0 | 003 7 | 1 | 003 I want to update the duplicate 1s ilno to 0. ...

Search a word in particular column in SQL server using stored procedure

Am trying to write an SQL server query for, Events which are in categories 5 or 6, but which don't mention either War or Death in the EventDetails column. Below I have mentioned my query, select ...

Apply the toggle for group in SSRS

I am developing an SSRS report and want to apply toggle for the groups. My data from the stored procedure is as below, Group InitialName Value Group A 1000 Group B ...

How to disable predeployment and postdeployment scripts in DacServices.Deploy()

We have some automated dacpac deployment code which correctly handles both a CreateNewDatabase and straightforward Update database scenarios in C# using Microsoft.SqlServer.Dac Now in the ...

How to repeat column until next value is encountered

I want to repeat the category column until the next value is encountered. Below is the structure of the table: Category Term Date -------------------- -------------- category1 a 12/...

How to access the server's Query Analyzer over the network?

I need to execute a SQL script from a remote machine. How can this be realized?

Sql function for statement

I have table below: Now I need the table like: Here:If TransType='Deposit' then it need in Debit and if TransType='Withdraw' then it need to be in Credit, And Debit-Credit from first to Last as ...

How to parse xml from column SQL Server

I have SQL Server 2012 installed. There is a table called channel_group that has multiple records in the table. [dbo].[CHANNEL_GROUP] ( [ID] [nvarchar](255) NOT NULL, [NAME] [nvarchar](255) ...

T-SQL select and update with lock - transaction or table hint

How to achieve following transaction lock? In big simplification - I have a table of "Tasks" with statuses (Created, Started, Completed). I want to create stored procedure GetNext to get top 1 task ...

Create alias for SQL server to use in query

My SQL server instance name is in the format: 'My-Server\InstanceName' I want to give the server the alias 'InstanceName'. I did this in the Configuration Manager. When I connect to the server, I'm ...

there is no check box in Instance Features

I try to install SQL Server 2008 R2, but there is no Checkbox Option in instance feature. I need help This is the error: Thank you

How to change default string representation of GETDATE() to include milliseconds?

I'm creating an tool called dbfiddle, and someone has asked how to get more precision from GETDATE() and SYSDATETIME(), which currently show seconds only: SELECT SYSDATETIME(), GETDATE(); GO (No ...

Which other teachers are teaching the courses that are being taught by John Cullen.SQL

I have multiple tables but for this query only need two tables those are Faculty and CourseSection. I have tried the following but failed.If someone can help. Select faculty.firstname,faculty....

CQRS: write to RDBMS, read from NoSQL?

I've been thinking on separation the read and write flows and even make them use different databases to provide best fast data availability by horizontally scaling the "read" databases. I'm gonna make ...

SQL Select with Distinct

With this data Team Name Won X Andy 1 X Cara 1 X Cara 1 X Eric 0 X Eric 0 X Eric 0 X Eric 0 Y Bill 0 Y Dave 0 Y Dave 1 Y Dave 1 I want for each team the ...

LocalDB: create db from existing SQL Server database

Just wondering if there's a quick way of creating a new localdb from an existing SQL Server database. The idea is to reproduce the "real" db structure in order to run some integration tests from the ...

show different row and column data in one column using sql query

My tabular data looks like DECLARE @Tab TABLE(Name VARCHAR(10), VAL INT) INSERT INTO @Tab VALUES('A',25),('B',30),('C',236),('D',217),('E',19) SELECT * FROM @Tab I want to show my result as: Total:...

SQL Server Bulk Insert - columns delimited by quotes and containing quotes

I'm trying to import a text file into SQL Server using BULK INSERT. Here's a sample line containing the exception I'm having issues with:: "AB123","Sample Data ""B"" Test",7/12/2007,"ABC","More ...

How to display Image from folder using ASP.NET MVC

I create entity outside my Project this is solution Explorer My entity Post [Table("Post")] public partial class Post { public int PostID { get; set; } [Required] [StringLength(256)] ...

Can anyone help me to write query in SQL Server [on hold]

I have A table with below structure: Case ============== [CaseNo] [int] NOT NULL, [IsLinked] [bit] NOT NULL, [LinkedCase1] [int] NULL, [LinkedCase2] [int] NULL, [LinkedCase3] [int] NULL, [LinkedCase4]...
Translating... 0%