Viewing 15 posts - 5,641 through 5,655 (of 8,731 total)
You should try a CROSS JOIN.
October 21, 2014 at 9:41 am
The problem is that you're getting the month for the "current" date instead of subtracting the week as you do in your convert.
Check this out:
SELECT GivenDate,
...
October 21, 2014 at 9:38 am
The problem is with your way to handle errors. You need to have a try-catch block for each statement.
I guess that you have something like this:
BEGIN TRY
...
October 20, 2014 at 5:07 pm
Do you have a try...catch block for each table/file?
Can you post what have you tried?
October 20, 2014 at 4:32 pm
Why would you use string manipulation when it's easier to work directly with the numbers using some math?
Here's a modification of Eirikur's code.
USE tempdb;
GO
DECLARE @SAMPLE_SIZE INT ...
October 20, 2014 at 3:38 pm
What do you mean by SQL compatible? SQL Server can't generate 100% SQL code. And no RDBMS can use it, either. SQL Server will generate T-SQL code which is the...
October 20, 2014 at 1:41 pm
This is an example on how to do it through dynamic code.
DECLARE @divisor int = 80,
@dividend int = 10,
@table varchar(128)...
October 20, 2014 at 12:28 pm
You can't do this. To be able to query different tables and columns, you need to use dynamic code. Dynamic code can be dangerous if it's not handled correctly and...
October 20, 2014 at 12:01 pm
Hi scantoria,
I'm glad that you read the questions. They weren't intended specifically for you, they're part of my signature and appear on all my posts. You wouldn't believe the amount...
October 19, 2014 at 6:32 pm
You could do something like this:
SELECT 'TableName1' AS ColumnA,
SomeColumn AS ColumnB
FROM TableName1
UNION ALL
SELECT 'TableName2' AS ColumnA,
SomeColumn AS ColumnB
FROM TableName2
October 17, 2014 at 5:56 pm
You just add a string literal as the column.
SELECTc.cust_fullname AS Name,
c.cust_membership_id AS Account,
t.c_amount AS Amount,
'CH' + CAST(t.i_ticket_id AS varchar(12)) AS Doc_Num,
t.s_credit_tran_type AS Detail_Account,
...
October 17, 2014 at 5:50 pm
No one would be capable of give any help with such little information. You're asking for a DB design but that can be a really big project and you might...
October 17, 2014 at 11:02 am
Could you post DDL for tables and sample data that will replicate the issue?
Table and column names can be changed if needed.
October 16, 2014 at 4:15 pm
Are you sure that's the problem?
If I run the following, it gives the correct result:
SELECT TBI.CurrDateTime,
CAST((LEFT(TBI.CurrDateTime, 10) + ' ' + RIGHT(RTRIM(LTRIM(TBI.CurrDateTime)), 15)) AS DATETIME2(6)),
...
October 16, 2014 at 3:36 pm
This was fun, but I'm not sure I have the complete solution. The difficult part is done without dynamic sql.
By the way, this seems like a really bad design, but...
October 16, 2014 at 1:50 pm
Viewing 15 posts - 5,641 through 5,655 (of 8,731 total)