Creating a asp webform to query a database with an input

I am trying to create a c# webform that displays information from a database based on a users input. My goal would be for a user to type a number in the Store Number box and that number be used in the where cause in the select statement. <%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”WebForm1.aspx.cs” Inherits=”WebApplication4.WebForm1″ %> […]

How can I link my Junction table to my main table

I have a SQL database with the main table called Results. This table stores a record of results of tests that are run nightly. The Results table has many fields but for arguments say lets just say for now it looks like this: ResultID (Unique key field generated upon insert) Result (nvchar10) What I wanted […]

SQL Server – Internal error: An expression services limit has been reached

I have a SQL Server stored procedure with nearly 300 variables within it. The variables were created as follows: CASE WHEN Grp1 = ‘SALES’ AND grp_mnth = MONTH_0 THEN SUM(Col) OVER(PARTITION BY grp_loc,COMM) ELSE 0 END AS “SALES_1” As this has data issue all the variables were replaced like: SUM(CASE WHEN Grp1 = ‘SALES’ AND […]

Different columns of the same name SQL Sorted by Column Names

I have a table in SQL Category | Subcategory | Region | Count | Percent | A | Aa | ON | 3 | 5% | A | Aa | AT | 1 | 2% | A | Ab | ON | 5 | 10% | B | Bc | AT | 1 | 21% […]

my query works in SQL but not in SSRS

Can someone please advise what I did wrong with the last WHERE clause? I have the following query that works fine in SQL: with t1 as (select ID, state, T, U, R, row_number() over (partition by ID, U order by T asc) as asc_T, row_number() over (partition by ID, U order by T desc) as […]

Create a SQL login for Windows user

$Username = “test-usr” [System.Reflection.Assembly]::LoadWithPartialName(‘Microsoft.SqlServer.SMO’) | out-null $SqlServer = New-Object (‘Microsoft.SqlServer.Management.Smo.Server’) “servername” $SqlUser = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Login -ArgumentList $SqlServer, “$Username” $SqlUser.LoginType = ‘WindowsUser’ $SqlUser.Create() Getting Exception as follows: Exception calling “Create” with “0” argument(s): “Create failed for Login ‘test-usr’. ” At line:7 char:1 + $SqlUser.Create() + ~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId […]

Concatenate row values into single row per group

I have a problem. Table-1 Name : InvoiceDetail InvoiceNo StockCode Piece ———- ———– —— 1 CP-001 10 1 CP-002 15 2 CP-001 18 2 MN-001 18 Table-2 Name : Stock StockCode StockName ———– ———– CP-001 Computer-A CP-002 Computer-B MN-001 Monitor-A Expected Result InvoiceNo Description TotalPiece ———- ———————– ———- 1 Computer-A, Computer-B 25 2 Computer-A, Monitor-A […]

TSQL – Using variable in xp_regread

Im trying to get the DefaultLog directory from a number of instances. The instancenames are stored in a temporary DB and I’m going through every row to get data about every instance. How can I get this code to work or is there a better way? This is just a very small extract but shows […]

Stored procedures – writing errors out to another table

I have two tables and a simple stored procedure. I want to use the stored procedure to insert into table1 with one of the parms being the primary key. Here is where I am having trouble: I want to have it so that if the parm/primary key the user has entered into the stored procedure […]

Isolating text from the middle of a varchar field in SQL Server

I have a varchar column in one of my tables, and I need to be able to isolate some text from the middle of it, so that I can use this to lookup information from another table. An example of the text this column might contain is like this: 0A10-Deeside PKG AHU-G37-Pa-A is out of […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.