ShrinkDatabase confusion
SQL 2005, 2008, 2012Have a process that creates DB1 by restoring from a db backup. Then hundred of tables in DB1 are truncated and copied from DB0. At the end there is a proc ShrinkDB that does the...
View Articlesum(attribute) grouped under rows and Weeknumber through using start and...
Second try I was simplifying my question and example a little to much I think. Now maybe it becomes to complex. if a given time Period is larger than available dates, just show available dates."Given...
View ArticleSnapshot of Fact Table
I'm working on a snapshot of a Fact. The snapshot's purpose is to record changes of columns x,y, and z. If either x,y, or z change in the Fact, a new row should be added to the Snapshot and flag...
View ArticleSelect XML data
Okay, this should be simple, but I can't get it to work. I have XML data in an ntext field (developers, what can you do), that I need to parse out a value from. The data looks like...
View ArticleSql server regular expression- grouping of characters inside the square bracket
Hi , I am searching for a string in the table in the sql server database, for that i am creating a regular expression as I need to search with different combination. select * from table where name...
View ArticleIs a Cast/Convert required here?
Just imagine all the right stuff is in between - the question is about the setting the xml @response = to the varchar @xml_output.CREATE PROCEDURE [dbo].[sp_test] (.... @response XML OUTPUT ) AS ......
View ArticleSomebody Please help me Translate this Vb.net(2008) code into sql query
I want to translate this vb.net code into sql query for optimizing the database connection (request time out) Database USE [dbBom] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE...
View ArticleHow can i use for each statement with condition in sql server
USE [TEST] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[JV]( [JvHeader_ID] [int] NULL, [Debit] [float] NULL, [credit] [float] NULL, [AC_Code_No] [int] NULL, [cal] [float]...
View Articlet-sql case statement in a select
When I execute the following t-sql 2012 statement, the "NO Prod' value is not being displayed from the sql listed below: SELECT DISTINCT IsNull(cs.TYPE,'') as type, CASE IsNull(Course.TYPE,'') WHEN...
View ArticleJoin 2 select statements
How would I combine the following 2 select statements, so the results end up in one row ?SELECT (SUM (CAST(Amount AS FLOAT))) AS 'Total Amoun', (COUNT(BranchCode))AS 'TOTAL COUNT' FROM [Transaction...
View ArticleLoop through Table
How would I make this query output the results for each account number in the table ?CREATE PROCEDURE [FinalReport] @AccNum nvarchar(50) SET @AccNum=(SELECT DISTINCT(AccountNumber) FROM [Transaction...
View Articleselect
Hello, There is a table as follows:create table #tblMain(ID int, MyID int, FromID int, ToID int)insert into #tblMain(ID, MyID, FromID, ToID) values(7, 5, 99, 353) insert into #tblMain(ID, MyID, FromID,...
View ArticleView with dynamic columns
Hello.I'm sure this must be a FAQ but can't find it anywhere.I'm collecting data from people in a questionnaire style but don't know what/how many questions there are. I need to create a view that...
View ArticleScript Execution Order
Hi,I'm getting the below scripts to be provided to DBA for deployment. The below renames "current" tables to OLD and NEW tables to "current". I would like it be executed in order. I always felt when F5...
View ArticleSQL Server Service is not reflecting to the new name.
Hi,I just rename the computer and use the command below to rename the SQL Server but the SQL Server Service is not reflecting to the new name.Is there a way to change the SQL Server Service and agent...
View ArticleStandardized Street Address Using T-SQL
I have an urgent requirement to standardize the Street Name. A fixed list of street suffixes are determined to be used.I am just curious if this is possible using T-SQL or I have to go for CLR.We are...
View ArticleQuartile Calculation in SQL Server 2008
Hi, I am using SQL Server 2008. I want to calculate the 0,1,2,3,4 Quartiles in SQL server. I tried with NTILE function. I am getting the quartile number I am not getting the values of the...
View ArticlePass parameters to ssis package through agent job.
I have a SSIS package that need couple of parameters to be mapped. The JOB is called from a Agent JOB and the JOB is called from a SP. How can I pass parameters via JOB?
View ArticleSQL Trigger based solution
Hi ALL ,I have Tables -Organization table with Columns :organizationid & OrganizationName .Customer table with with Columns :CustomerID , CustomerName & AreaIDMy Requirement is too trigger an...
View Article