sql-server-2008

What is the best way to allow a user to add columns to their database on-the-fly? [closed]

允我心安 提交于 2021-02-07 08:05:16
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question We're looking at designing an application for managing contact information. One of the customer's requests is to allow their powerusers or admin-type staff to add columns to the database through the UI. Customers do not have direct access to the database

Combine XML from T-SQL

拥有回忆 提交于 2021-02-07 07:24:10
问题 I have two separate tables TVs and Receivers that I am using the FOR XML PATH commands to build XML off of. My issue is that I want to combine the output of my TV XML Build with my Receiver XML Build to create one XML output. So I would have something like this(Which allows me to keep the TVs and Receivers Tags Separate within the FilterData Root): <FilterData> <TVs> <TV> <Type>LCD</Type> <Brand>Samsung</Brand> </TV> <TV> <Type>LCD</Type> <Brand>Panasonic</Brand> </TV> </TVs> <Receivers>

How to find loginname, database username, or roles of sqlserver domain user who doesn't have their own login?

折月煮酒 提交于 2021-02-06 10:58:41
问题 I have created a login and database user called "MYDOMAIN\Domain Users". I need to find what roles a logged on domain user has but all the calls to get the current user return the domain username eg. "MYDOMAIN\username" not the database username eg. "MYDOMAIN\Domain Users". For example, this query returns "MYDOMAIN\username" select original_login(),suser_name(), suser_sname(), system_user, session_user, current_user, user_name() And this query returns 0 select USER_ID() I want the username to

How to find loginname, database username, or roles of sqlserver domain user who doesn't have their own login?

自闭症网瘾萝莉.ら 提交于 2021-02-06 10:57:14
问题 I have created a login and database user called "MYDOMAIN\Domain Users". I need to find what roles a logged on domain user has but all the calls to get the current user return the domain username eg. "MYDOMAIN\username" not the database username eg. "MYDOMAIN\Domain Users". For example, this query returns "MYDOMAIN\username" select original_login(),suser_name(), suser_sname(), system_user, session_user, current_user, user_name() And this query returns 0 select USER_ID() I want the username to

Split String Column values

僤鯓⒐⒋嵵緔 提交于 2021-02-05 07:56:25
问题 acctcode primekey groupby <--- columns WDS 1 'NULL' <--- values (varchar) FDS 2 'NULL' IRN 3 'NULL' SUM 4 1,2,3 STL 5 'NULL' WTR 6 'NULL' SUM2 7 5,6 I want to split string groupby column where values are NOT EQUAL to 'NULL' and save it to another table which will look like this: acctcode primekey groupby SUM 4 1 SUM 4 2 SUM 4 3 SUM2 7 5 SUM2 7 6 here is my split string code: ALTER FUNCTION [dbo].[SplitStrings] ( @List NVARCHAR(MAX), @Delimiter NVARCHAR(255) ) RETURNS TABLE WITH SCHEMABINDING

C# creating a database programmatically with SMO

核能气质少年 提交于 2021-02-05 07:49:08
问题 I am trying to create a database, but once created, I cannot connect to it. The server is Microsoft SQL Server 2008 and using .Net 4.5. We're creating the database with SMO, but we're usually using Dapper to connect and query the database. This is the code I have so far, which works : System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(connectionString); Microsoft.SqlServer.Management.Smo.Server srv = new Microsoft.SqlServer.Management.Smo.Server(new Microsoft

Storing dynamic Pivot result into a temporary table in SQL Server

ε祈祈猫儿з 提交于 2021-02-05 07:18:45
问题 I have the following schema and sample data. create table MyTable ( Id int, Year int, Channel varchar(10), Payments int ) insert into MyTable values (1,2012,'HV',100), (1,2014,'HV',56), (2,2012,'NL',17000) (2,2012,'HV',495), (3,2013,'HV',565) Now I want to create and insert dynamic pivot data in a temporary table. I am able to create the pivot data as the demo here. But I want to store this data into a temporary table. What I have tried is as below. Declare @SQL varchar(max) = ' if object_id(

SQL Server stored procedure and execute in VB.NET

天涯浪子 提交于 2021-02-04 12:34:58
问题 This is a bit old-contents to be discussed but I need someone who can explain me how to create stored procedure in SQL Server for returning a value from procedure, example: SELECT NAME, ADDRESS FROM CUSTOMER WHERE IDCUSTOMER = 'DS212'; Then I need the name of its customer and the address instead. I need to make it as a stored procedure and show me how to execute it on VB.NET. Perhaps we assume that the name will be prompted to LABEL1.TEXT and the address will be prompted to LABEL2.TEXT. I've

SQL Server stored procedure and execute in VB.NET

試著忘記壹切 提交于 2021-02-04 12:34:28
问题 This is a bit old-contents to be discussed but I need someone who can explain me how to create stored procedure in SQL Server for returning a value from procedure, example: SELECT NAME, ADDRESS FROM CUSTOMER WHERE IDCUSTOMER = 'DS212'; Then I need the name of its customer and the address instead. I need to make it as a stored procedure and show me how to execute it on VB.NET. Perhaps we assume that the name will be prompted to LABEL1.TEXT and the address will be prompted to LABEL2.TEXT. I've

How To Traverse a Tree/Work With Hierarchical data in SQL Code

回眸只為那壹抹淺笑 提交于 2021-02-04 10:48:28
问题 Say I have an employee table, with a record for each employee in my company, and a column for supervisor (as seen below). I would like to prepare a report, which lists the names and title for each step in a supervision line. eg for dick robbins, 1d #15, i'd like a list of each supervisor in his "chain of command," all the way to the president, big cheese. I'd like to avoid using cursors, but if that's the only way to do this then that's ok. id fname lname title supervisorid 1 big cheese